Browse files

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


paths. Self-referential relations (e.g. ForeignKey('self')) were still slipping
through the net. Refs #1796.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
malcolmt committed Jul 6, 2006
1 parent e8ef80c commit c63dcdda372d4d8a37abd39432deb62b8d4b1d23
Showing with 5 additions and 0 deletions.
  1. +5 −0 django/db/models/
@@ -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)

0 comments on commit c63dcdd

Please sign in to comment.