Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix django.contrib.sites detection in set_default_site command when using AppConfig #1662

Merged

Conversation

azaghal
Copy link
Contributor

@azaghal azaghal commented Apr 27, 2021

The purpose of this pull request is to improve django.contrib.sites application detection in the set_default_site command. Currently the command depends on having the name hardcoded in settings.INSTALLED_APPS, which could lead to not being able to detect the application if it is installed through the AppConfig class/mechanism.

Instead of the simple string check, the changed implementation uses application registry.

While not something that is common (I literally found one project that listed the django.contrib.sites.apps.SitesConfig in its example config), the small fix I propose is probably more robust than the existing one.

…sing AppConfig in INSTALLED_APPS:

django.contrib.sites application can be specified in installed
application list either via its module path, or via its AppConfig
path. This can be either the default
one (django.contrib.sites.apps.SitesConfig), or user-provided
AppConfig class.

Instead of relying on a fixed name in the settings files, use the
application registry to check if the sites application is installed.
@trbs trbs merged commit 1a1e50e into django-extensions:main May 2, 2021
@trbs
Copy link
Member

trbs commented May 2, 2021

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants