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
This commit is contained in:
Malcolm Tredinnick 2006-07-06 13:25:12 +00:00
parent e8ef80c130
commit c63dcdda37
1 changed files with 5 additions and 0 deletions

View File

@ -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)