Ticket #2982: django_models.diff
File django_models.diff, 1.1 KB (added by , 18 years ago) |
---|
-
django/db/models/base.py
39 39 model_module = sys.modules[new_class.__module__] 40 40 41 41 if getattr(new_class._meta, 'app_label', None) is None: 42 # Figure out the app_label by looking one level up .42 # Figure out the app_label by looking one level up above 'models'. 43 43 # For 'django.contrib.sites.models', this would be 'sites'. 44 new_class._meta.app_label = model_module.__name__.split('.')[-2] 44 modparts = model_module.__name__.split('.') 45 # search the first 'models' module name, which 46 # a) must exist and b) must have a leading module part 47 assert 'models' in modparts 48 idx = modparts.index('models') 49 assert idx > 0 50 new_class._meta.app_label = modparts[idx-1] 45 51 46 52 # Bail out early if we have already created this class. 47 53 m = get_model(new_class._meta.app_label, name, False)