From c63dcdda372d4d8a37abd39432deb62b8d4b1d23 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Thu, 6 Jul 2006 13:25:12 +0000 Subject: [PATCH] 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 --- django/db/models/base.py | 5 +++++ 1 file changed, 5 insertions(+) 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)