summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-07-06 13:25:12 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2006-07-06 13:25:12 +0000
commitc63dcdda372d4d8a37abd39432deb62b8d4b1d23 (patch)
tree4d80f9bc5349b3e1d1e19fdb4961d6b4fbc4f78d
parente8ef80c1301a4a20ef3f41b980d42242639c8527 (diff)
Fixed another problem where we were creating a class twice via two import
paths. Self-referential relations (e.g. ForeignKey('self')) were still slipping through the net. Refs #1796. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3279 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-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)