mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #21829 -- Added default AppConfigs.
Thanks Russell for the report, Marc for the initial patch, Carl for the final review, and everyone who contributed to the design discussion.
This commit is contained in:
parent
29ddae7436
commit
2ff93e027c
36 changed files with 194 additions and 111 deletions
|
@ -1113,7 +1113,7 @@ class ManageCheck(AdminScriptTestCase):
|
|||
apps=[
|
||||
'admin_scripts.complex_app',
|
||||
'admin_scripts.simple_app',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
],
|
||||
|
|
1
tests/apps/default_config_app/__init__.py
Normal file
1
tests/apps/default_config_app/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
default_app_config = 'apps.default_config_app.apps.CustomConfig'
|
5
tests/apps/default_config_app/apps.py
Normal file
5
tests/apps/default_config_app/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CustomConfig(AppConfig):
|
||||
name = 'apps.default_config_app'
|
|
@ -7,6 +7,7 @@ from django.db import models
|
|||
from django.test import TestCase, override_settings
|
||||
from django.utils import six
|
||||
|
||||
from .default_config_app.apps import CustomConfig
|
||||
from .models import TotallyNormal, SoAlternative, new_apps
|
||||
|
||||
|
||||
|
@ -82,6 +83,11 @@ class AppsTests(TestCase):
|
|||
with self.settings(INSTALLED_APPS=['apps.apps.NoSuchConfig']):
|
||||
pass
|
||||
|
||||
def test_default_app_config(self):
|
||||
with self.settings(INSTALLED_APPS=['apps.default_config_app']):
|
||||
config = apps.get_app_config('default_config_app')
|
||||
self.assertIsInstance(config, CustomConfig)
|
||||
|
||||
@override_settings(INSTALLED_APPS=SOME_INSTALLED_APPS)
|
||||
def test_get_app_configs(self):
|
||||
"""
|
||||
|
|
|
@ -1049,7 +1049,7 @@ class AppResolutionOrderI18NTests(ResolutionOrderI18NTests):
|
|||
# Doesn't work because it's added later in the list.
|
||||
self.assertUgettext('Date/time', 'Datum/Zeit')
|
||||
|
||||
with self.modify_settings(INSTALLED_APPS={'remove': 'django.contrib.admin'}):
|
||||
with self.modify_settings(INSTALLED_APPS={'remove': 'django.contrib.admin.apps.SimpleAdminConfig'}):
|
||||
self.flush_caches()
|
||||
activate('de')
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ ALWAYS_INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.comments',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.admin.apps.SimpleAdminConfig',
|
||||
'django.contrib.admindocs',
|
||||
'django.contrib.staticfiles',
|
||||
'django.contrib.humanize',
|
||||
|
@ -168,12 +168,11 @@ def setup(verbosity, test_labels):
|
|||
for label in test_labels_set)
|
||||
|
||||
installed_app_names = set(get_installed())
|
||||
if module_found_in_labels:
|
||||
if module_found_in_labels and module_label not in installed_app_names:
|
||||
if verbosity >= 2:
|
||||
print("Importing application %s" % module_name)
|
||||
# HACK.
|
||||
if module_label not in installed_app_names:
|
||||
settings.INSTALLED_APPS.append(module_label)
|
||||
settings.INSTALLED_APPS.append(module_label)
|
||||
app_config = AppConfig.create(module_label)
|
||||
apps.app_configs[app_config.label] = app_config
|
||||
app_config.import_models(apps.all_models[app_config.label])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue