Ticket #1437: enable_models_outside_models_py.diff

File enable_models_outside_models_py.diff, 1.8 KB (added by Luke Plant, 19 years ago)

Patch to implement this ticket

  • django/db/models/base.py

     
    2525            return type.__new__(cls, name, bases, attrs)
    2626
    2727        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)
    2832
    2933        # Raise ImportError if this model isn't in INSTALLED_APPS.
    3034        if re.sub('\.models$', '', mod) not in settings.INSTALLED_APPS:
     
    3236
    3337        # Create the class.
    3438        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))
    3640        new_class.add_to_class('DoesNotExist', types.ClassType('DoesNotExist', (ObjectDoesNotExist,), {}))
    3741
    3842        # Build complete list of parents
  • django/db/models/options.py

     
    1212
    1313DEFAULT_NAMES = ('verbose_name', 'verbose_name_plural', 'db_table', 'ordering',
    1414                 'unique_together', 'permissions', 'get_latest_by',
    15                  'order_with_respect_to', 'app_label')
     15                 'order_with_respect_to', 'app_label', 'module')
    1616
    1717class Options:
    1818    def __init__(self, meta):
     
    2424        self.unique_together =  []
    2525        self.permissions =  []
    2626        self.object_name, self.app_label = None, None
     27        self.module = None
    2728        self.get_latest_by = None
    2829        self.order_with_respect_to = None
    2930        self.admin = None
Back to Top