File: checks.py

package info (click to toggle)
python-daphne 4.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 392 kB
  • sloc: python: 2,593; makefile: 28
file content (21 lines) | stat: -rw-r--r-- 722 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Django system check to ensure daphne app is listed in INSTALLED_APPS before django.contrib.staticfiles.
from django.core.checks import Error, register


@register()
def check_daphne_installed(app_configs, **kwargs):
    from django.apps import apps
    from django.contrib.staticfiles.apps import StaticFilesConfig

    from daphne.apps import DaphneConfig

    for app in apps.get_app_configs():
        if isinstance(app, DaphneConfig):
            return []
        if isinstance(app, StaticFilesConfig):
            return [
                Error(
                    "Daphne must be listed before django.contrib.staticfiles in INSTALLED_APPS.",
                    id="daphne.E001",
                )
            ]