django-flat-theme
django-flat-theme copied to clipboard
Ensure INSTALLED_APPS sanity for flat app according to Django version
Closes https://github.com/elky/django-flat-theme/issues/36
This solution is similar to https://github.com/fabiocaccamo/django-admin-interface/blob/master/admin_interface/settings.py
@filwaitman thank you for your PR. Thing you're suggesting is really useful.
One only thing - we shouldn't use ImproperlyConfigured because some people use their own fork of flat app. This exception will break their project.
Let's use Warning message instead:
import django
from django.conf import settings
from django.core.checks import Warning, register
@register()
def check_installed_apps(app_configs, **kwargs):
warnings = []
if django.VERSION[:2] >= (1, 9) and 'flat' in settings.INSTALLED_APPS:
warnings.append(Warning(
"'flat' app is included as part of Django from version 1.9.",
hint='Please remove it from INSTALLED_APPS.',
id='flat.W001',
))
return warnings
then make sure you pass self to check_installed_apps in apps.py
Many thanks!