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:
parent
e8ef80c130
commit
c63dcdda37
|
@ -44,6 +44,11 @@ class ModelBase(type):
|
||||||
# For 'django.contrib.sites.models', this would be 'sites'.
|
# For 'django.contrib.sites.models', this would be 'sites'.
|
||||||
new_class._meta.app_label = model_module.__name__.split('.')[-2]
|
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.
|
# Add all attributes to the class.
|
||||||
for obj_name, obj in attrs.items():
|
for obj_name, obj in attrs.items():
|
||||||
new_class.add_to_class(obj_name, obj)
|
new_class.add_to_class(obj_name, obj)
|
||||||
|
|
Loading…
Reference in New Issue