diff --git a/django/db/models/base.py b/django/db/models/base.py index e69d59c56f..0b2adc716c 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -14,7 +14,6 @@ from django.dispatch import dispatcher from django.utils.datastructures import SortedDict from django.utils.functional import curry from django.conf import settings -import re import types import sys import os @@ -26,14 +25,8 @@ class ModelBase(type): if not bases or bases == (object,): return type.__new__(cls, name, bases, attrs) - mod = attrs.pop('__module__') - - # Raise ImportError if this model isn't in INSTALLED_APPS. - if re.sub('\.models$', '', mod) not in settings.INSTALLED_APPS: - raise ImportError, "INSTALLED_APPS must contain %r in order for you to use this model." % re.sub('\.models$', '', mod) - # Create the class. - new_class = type.__new__(cls, name, bases, {'__module__': mod}) + new_class = type.__new__(cls, name, bases, {'__module__': attrs.pop('__module__')}) new_class.add_to_class('_meta', Options(attrs.pop('Meta', None))) new_class.add_to_class('DoesNotExist', types.ClassType('DoesNotExist', (ObjectDoesNotExist,), {})) diff --git a/django/db/models/options.py b/django/db/models/options.py index 1693623702..b318599fcc 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.db.models.related import RelatedObject from django.db.models.fields.related import ManyToManyRel from django.db.models.fields import AutoField, FieldDoesNotExist @@ -35,6 +36,7 @@ class Options: def contribute_to_class(self, cls, name): cls._meta = self + self.installed = re.sub('\.models$', '', cls.__module__) in settings.INSTALLED_APPS # First, construct the default values for these options. self.object_name = cls.__name__ self.module_name = self.object_name.lower()