Ticket #8108: 8108.diff
File 8108.diff, 1.6 KB (added by , 16 years ago) |
---|
-
django/db/models/base.py
11 11 import django.db.models.manipulators # Imported to register signal handler. 12 12 import django.db.models.manager # Ditto. 13 13 from django.core import validators 14 from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError 14 from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError, ImproperlyConfigured 15 15 from django.db.models.fields import AutoField, ImageField 16 16 from django.db.models.fields.related import OneToOneRel, ManyToOneRel, OneToOneField 17 17 from django.db.models.query import delete_objects, Q, CollectedObjects … … 53 53 # Figure out the app_label by looking one level up. 54 54 # For 'django.contrib.sites.models', this would be 'sites'. 55 55 model_module = sys.modules[new_class.__module__] 56 kwargs = {"app_label": model_module.__name__.split('.')[-2]} 56 try: 57 app_label = model_module.__name__.split('.')[-2] 58 except IndexError: 59 if abstract: 60 app_label = '_abstract' 61 else: 62 raise ImproperlyConfigured, \ 63 "Model definitions in '%s' module must reside in an app-level subdirectory within your project or have a defined app_label" \ 64 % (model_module.__name__) 65 kwargs = {"app_label": app_label} 57 66 else: 58 67 kwargs = {} 59 68