Code

Ticket #18975: 18975.diff

File 18975.diff, 1.2 KB (added by FunkyBob, 19 months ago)

Passes on git rev 9db7652

Line 
1diff --git a/django/db/models/loading.py b/django/db/models/loading.py
2index 7a9cb2c..5808036 100644
3--- a/django/db/models/loading.py
4+++ b/django/db/models/loading.py
5@@ -231,15 +231,7 @@ class AppCache(object):
6             model_name = model._meta.object_name.lower()
7             model_dict = self.app_models.setdefault(app_label, SortedDict())
8             if model_name in model_dict:
9-                # The same model may be imported via different paths (e.g.
10-                # appname.models and project.appname.models). We use the source
11-                # filename as a means to detect identity.
12-                fname1 = os.path.abspath(sys.modules[model.__module__].__file__)
13-                fname2 = os.path.abspath(sys.modules[model_dict[model_name].__module__].__file__)
14-                # Since the filename extension could be .py the first time and
15-                # .pyc or .pyo the second time, ignore the extension when
16-                # comparing.
17-                if os.path.splitext(fname1)[0] == os.path.splitext(fname2)[0]:
18+                if model is model_dict[model_name]:
19                     continue
20             model_dict[model_name] = model
21         self._get_models_cache.clear()