From 1f5268a01f82c314b48d195b7d7a344f9db58b6d Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 19 Jan 2014 18:09:52 +0000 Subject: [PATCH] Fixed #21786: Bad behaviour when mixins + abstract bases for migrations --- django/db/migrations/state.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index 3bc7837089..ab4c4be2f7 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -147,11 +147,16 @@ class ModelState(object): 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,