Ticket #4193: 4193_model_registry_fix.diff

File 4193_model_registry_fix.diff, 927 bytes (added by Brian Rosner, 17 years ago)

possible patch that maintains model ordering in the app cache since SQL creation depends on it.

  • django/db/models/loading.py

     
    22
    33from django.conf import settings
    44from django.core.exceptions import ImproperlyConfigured
     5from django.utils.datastructures import SortedDict
    56import sys
    67import os
    78import threading
     
    159160            # Store as 'name: model' pair in a dictionary
    160161            # in the _app_models dictionary
    161162            model_name = model._meta.object_name.lower()
    162             model_dict = self.app_models.setdefault(app_label, {})
     163            model_dict = self.app_models.setdefault(app_label, SortedDict())
    163164            if model_name in model_dict:
    164165                # The same model may be imported via different paths (e.g.
    165166                # appname.models and project.appname.models). We use the source
Back to Top