Django

Code

Changeset 3212

Show
Ignore:
Timestamp:
06/26/06 11:20:58 (2 years ago)
Author:
mtredinnick
Message:

Fixed another path where imports were creating two instances of a model's
class. Refs #1796, #2232.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/base.py

    r3168 r3212  
    1010from django.db import connection, backend, transaction 
    1111from django.db.models import signals 
    12 from django.db.models.loading import register_models 
     12from django.db.models.loading import register_models, get_model 
    1313from django.dispatch import dispatcher 
    1414from django.utils.datastructures import SortedDict 
     
    6161 
    6262        register_models(new_class._meta.app_label, new_class) 
    63         return new_class 
     63        # Because of the way imports happen (recursively), we may or may not be 
     64        # the first class for this model to register with the framework. There 
     65        # should only be one class for each model, so we must always return the 
     66        # registered version. 
     67        return get_model(new_class._meta.app_label, name) 
    6468 
    6569class Model(object): 
  • django/trunk/django/db/models/loading.py

    r3206 r3212  
    7474    Returns None if no model is found. 
    7575    """ 
    76     get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish. 
    7776    try: 
    7877        model_dict = _app_models[app_label]