.. _whitenoise: .. index:: single: Whitenoise single: statische Dateien single: WSGI single: Whitenoise ********************************* Whitenoise ist ein Modul, um statische Dateien über eine WSGI-komptatible App auszuliefern. Insbesondere ist es geeignet, Header mit expires zu senden, um Caching zu optimieren. Whitenoise installieren ------------------------- .. code-block:: bash (env) pip install whitenoise Settings konfigurieren ------------------------ .. code-block:: python STATIC_ROOT = BASE_DIR / 'staticfiles' direkt nach der ``SecurityMiddleware`` .. code-block:: python MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', # ... ] ganz oben vor ``django.contrib.staticfiles`` .. code-block:: python INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", 'whitenoise.runserver_nostatic', "django.contrib.staticfiles", "django.contrib.admindocs", "crispy_forms", "rest_framework", "rest_framework.authtoken", # "easy_pdf", ]