Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…el's

class. Refs #1796, #2232.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3212 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 919df8b8c7b268105260a8d08d4308dc3cd34a25 1 parent d2b9523
@malcolmt malcolmt authored
Showing with 6 additions and 3 deletions.
  1. +6 −2 django/db/models/base.py
  2. +0 −1  django/db/models/loading.py
View
8 django/db/models/base.py
@@ -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):
new_class._prepare()
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
View
1  django/db/models/loading.py
@@ -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.
try:
model_dict = _app_models[app_label]
except KeyError:

0 comments on commit 919df8b

Please sign in to comment.
Something went wrong with that request. Please try again.