Ticket #1812: loading-getapp.diff

File loading-getapp.diff, 804 bytes (added by Matt McClanahan, 18 years ago)

Add an ImproperlyConfigured exception when an app has no models module

  • django/db/models/loading.py

     
    2626    "Returns the module containing the models for the given app_label."
    2727    for app_name in settings.INSTALLED_APPS:
    2828        if app_label == app_name.split('.')[-1]:
    29             return __import__(app_name, '', '', ['models']).models
     29            try:
     30                return __import__(app_name, '', '', ['models']).models
     31            except AttributeError:
     32                raise ImproperlyConfigured, "Models for app with label %s could not be found" % app_label
    3033    raise ImproperlyConfigured, "App with label %s could not be found" % app_label
    3134
    3235def get_models(app_mod=None):
Back to Top