Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 1f5268a01f82c314b48d195b7d7a344f9db58b6d 1 parent af4a847
Andrew Godwin authored January 19, 2014

Showing 1 changed file with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. 9  django/db/migrations/state.py
9  django/db/migrations/state.py
@@ -147,11 +147,16 @@ def from_model(cls, model):
147 147
                     options[name] = model._meta.original_attrs[name]
148 148
         # Make our record
149 149
         bases = tuple(
150  
-            ("%s.%s" % (base._meta.app_label, base._meta.model_name) if hasattr(base, "_meta") else base)
  150
+            (
  151
+                "%s.%s" % (base._meta.app_label, base._meta.model_name)
  152
+                if hasattr(base, "_meta") else
  153
+                base
  154
+            )
151 155
             for base in model.__bases__
152 156
             if (not hasattr(base, "_meta") or not base._meta.abstract)
153 157
         )
154  
-        if not bases:
  158
+        # Ensure at least one base inherits from models.Model
  159
+        if not any((isinstance(base, six.string_types) or issubclass(base, models.Model)) for base in bases):
155 160
             bases = (models.Model, )
156 161
         return cls(
157 162
             model._meta.app_label,

0 notes on commit 1f5268a

Please sign in to comment.
Something went wrong with that request. Please try again.