Browse files

Fixed another path where imports were creating two instances of a mod…


class. Refs #1796, #2232.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent d2b9523 commit 919df8b8c7b268105260a8d08d4308dc3cd34a25 @malcolmt malcolmt committed Jun 26, 2006
Showing with 6 additions and 3 deletions.
  1. +6 −2 django/db/models/
  2. +0 −1 django/db/models/
@@ -9,7 +9,7 @@
from django.db.models.options import Options, AdminOptions
from django.db import connection, backend, transaction
from django.db.models import signals
-from django.db.models.loading import register_models
+from django.db.models.loading import register_models, get_model
from django.dispatch import dispatcher
from django.utils.datastructures import SortedDict
from django.utils.functional import curry
@@ -60,7 +60,11 @@ def __new__(cls, name, bases, attrs):
register_models(new_class._meta.app_label, new_class)
- return new_class
+ # Because of the way imports happen (recursively), we may or may not be
+ # the first class for this model to register with the framework. There
+ # should only be one class for each model, so we must always return the
+ # registered version.
+ return get_model(new_class._meta.app_label, name)
class Model(object):
__metaclass__ = ModelBase
@@ -73,7 +73,6 @@ def get_model(app_label, model_name):
Returns the model matching the given app_label and case-insensitive model_name.
Returns None if no model is found.
- get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish.
model_dict = _app_models[app_label]
except KeyError:

0 comments on commit 919df8b

Please sign in to comment.