summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/models/base.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 442220abd4..c89033c491 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -44,6 +44,11 @@ class ModelBase(type):
# For 'django.contrib.sites.models', this would be 'sites'.
new_class._meta.app_label = model_module.__name__.split('.')[-2]
+ # Bail out early if we have already created this class.
+ m = get_model(new_class._meta.app_label, name)
+ if m is not None:
+ return m
+
# Add all attributes to the class.
for obj_name, obj in attrs.items():
new_class.add_to_class(obj_name, obj)