Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 1f5268a01f82c314b48d195b7d7a344f9db58b6d 1 parent af4a847
@andrewgodwin andrewgodwin authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 django/db/migrations/state.py
View
9 django/db/migrations/state.py
@@ -147,11 +147,16 @@ def from_model(cls, model):
options[name] = model._meta.original_attrs[name]
# Make our record
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__
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, )
return cls(
model._meta.app_label,
Please sign in to comment.
Something went wrong with that request. Please try again.