Ticket #1437: enable_models_outside_models_py.diff
File enable_models_outside_models_py.diff, 1.8 KB (added by , 19 years ago) |
---|
-
django/db/models/base.py
25 25 return type.__new__(cls, name, bases, attrs) 26 26 27 27 mod = attrs.pop('__module__') 28 meta = attrs.pop('Meta', None) 29 if meta is not None: 30 # Allow module to be overridden using Meta 31 mod = getattr(meta, 'module', mod) 28 32 29 33 # Raise ImportError if this model isn't in INSTALLED_APPS. 30 34 if re.sub('\.models$', '', mod) not in settings.INSTALLED_APPS: … … 32 36 33 37 # Create the class. 34 38 new_class = type.__new__(cls, name, bases, {'__module__': mod}) 35 new_class.add_to_class('_meta', Options( attrs.pop('Meta', None)))39 new_class.add_to_class('_meta', Options(meta)) 36 40 new_class.add_to_class('DoesNotExist', types.ClassType('DoesNotExist', (ObjectDoesNotExist,), {})) 37 41 38 42 # Build complete list of parents -
django/db/models/options.py
12 12 13 13 DEFAULT_NAMES = ('verbose_name', 'verbose_name_plural', 'db_table', 'ordering', 14 14 'unique_together', 'permissions', 'get_latest_by', 15 'order_with_respect_to', 'app_label' )15 'order_with_respect_to', 'app_label', 'module') 16 16 17 17 class Options: 18 18 def __init__(self, meta): … … 24 24 self.unique_together = [] 25 25 self.permissions = [] 26 26 self.object_name, self.app_label = None, None 27 self.module = None 27 28 self.get_latest_by = None 28 29 self.order_with_respect_to = None 29 30 self.admin = None