Fixed #21786: Bad behaviour when mixins + abstract bases for migrations

This commit is contained in:
Andrew Godwin 2014-01-19 18:09:52 +00:00
parent af4a8478e4
commit 1f5268a01f
1 changed files with 7 additions and 2 deletions

View File

@ -147,11 +147,16 @@ class ModelState(object):
options[name] = model._meta.original_attrs[name] options[name] = model._meta.original_attrs[name]
# Make our record # Make our record
bases = tuple( bases = tuple(
("%s.%s" % (base._meta.app_label, base._meta.model_name) if hasattr(base, "_meta") else base) (
"%s.%s" % (base._meta.app_label, base._meta.model_name)
if hasattr(base, "_meta") else
base
)
for base in model.__bases__ for base in model.__bases__
if (not hasattr(base, "_meta") or not base._meta.abstract) if (not hasattr(base, "_meta") or not base._meta.abstract)
) )
if not bases: # Ensure at least one base inherits from models.Model
if not any((isinstance(base, six.string_types) or issubclass(base, models.Model)) for base in bases):
bases = (models.Model, ) bases = (models.Model, )
return cls( return cls(
model._meta.app_label, model._meta.app_label,