mirror of
https://github.com/django/django.git
synced 2025-10-03 23:34:47 +00:00
Normalized Model._meta.installed.
Used the information from the app cache instead of creating a duplicate based on INSTALLED_APPS. Model._meta.installed is no longer writable. It was a rather sketchy way to alter private internals anyway.
This commit is contained in:
parent
0242c56fd8
commit
7eea9bf303
7 changed files with 34 additions and 23 deletions
|
@ -91,13 +91,21 @@ class Options(object):
|
|||
# A custom AppCache to use, if you're making a separate model set.
|
||||
self.app_cache = app_cache
|
||||
|
||||
@property
|
||||
def app_config(self):
|
||||
# Don't go through get_app_config to avoid triggering populate().
|
||||
return self.app_cache.app_configs[self.app_label]
|
||||
|
||||
@property
|
||||
def installed(self):
|
||||
return self.app_config.installed
|
||||
|
||||
def contribute_to_class(self, cls, name):
|
||||
from django.db import connection
|
||||
from django.db.backends.utils import truncate_name
|
||||
|
||||
cls._meta = self
|
||||
self.model = cls
|
||||
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.model_name = self.object_name.lower()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue