django-flat-theme icon indicating copy to clipboard operation
django-flat-theme copied to clipboard

Ensure INSTALLED_APPS sanity for flat app according to Django version

Open filwaitman opened this issue 7 years ago • 1 comments

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 avatar Nov 05 '18 18:11 filwaitman

@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!

elky avatar Apr 15 '19 10:04 elky