Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed another problem where we were creating a class twice via two im…

…port

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
  • Loading branch information...
commit c63dcdda372d4d8a37abd39432deb62b8d4b1d23 1 parent e8ef80c
@malcolmt malcolmt authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 django/db/models/base.py
View
5 django/db/models/base.py
@@ -44,6 +44,11 @@ def __new__(cls, name, bases, attrs):
# 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)
Please sign in to comment.
Something went wrong with that request. Please try again.