Enforce manager_inheritance_from_future on every model

This commit is contained in:
Diederik van der Boor
2018-02-05 13:25:32 +01:00
parent a6aa95c07e
commit ea53b995a1
+9
View File
@@ -63,6 +63,15 @@ class PolymorphicModelBase(ModelBase):
if not attrs and model_name == 'NewBase':
return super(PolymorphicModelBase, self).__new__(self, model_name, bases, attrs)
# Make sure that manager_inheritance_from_future is set, since django-polymorphic 1.x already
# simulated that behavior on the polymorphic manager to all subclasses behave like polymorphics
if django.VERSION < (2, 0):
if 'Meta' in attrs:
if not hasattr(attrs['Meta'], 'manager_inheritance_from_future'):
attrs['Meta'].manager_inheritance_from_future = True
else:
attrs['Meta'] = type('Meta', (object,), {'manager_inheritance_from_future': True})
# create new model
new_class = self.call_superclass_new_method(model_name, bases, attrs)