Commit 48941bf020bf0bbfb37ba2d06a9fcd350842d31c
1 parent
b8a4f8d1
Making app installation detection more robust.
This conforms with `AppConfig` functionality and its use in `INSTALLED_APPS`. See https://docs.djangoproject.com/en/stable/ref/applications/#configuring-applications.
Showing
1 changed file
with
3 additions
and
2 deletions
| 1 | from importlib import import_module | 1 | from importlib import import_module |
| 2 | 2 | ||
| 3 | +from django.apps import apps | ||
| 3 | from django.conf import settings | 4 | from django.conf import settings |
| 4 | from django.core import urlresolvers | 5 | from django.core import urlresolvers |
| 5 | from django.core.exceptions import ImproperlyConfigured | 6 | from django.core.exceptions import ImproperlyConfigured |
| @@ -14,9 +15,9 @@ def get_comment_app(): | @@ -14,9 +15,9 @@ def get_comment_app(): | ||
| 14 | """ | 15 | """ |
| 15 | # Make sure the app's in INSTALLED_APPS | 16 | # Make sure the app's in INSTALLED_APPS |
| 16 | comments_app = get_comment_app_name() | 17 | comments_app = get_comment_app_name() |
| 17 | - if comments_app not in settings.INSTALLED_APPS: | 18 | + if not apps.is_installed(comments_app): |
| 18 | raise ImproperlyConfigured( | 19 | raise ImproperlyConfigured( |
| 19 | - "The COMMENTS_APP (%r) must be in INSTALLED_APPS" % settings.COMMENTS_APP | 20 | + "The COMMENTS_APP (%r) must be in INSTALLED_APPS" % comments_app |
| 20 | ) | 21 | ) |
| 21 | 22 | ||
| 22 | # Try to import the package | 23 | # Try to import the package |
Please
register
or
login
to post a comment