Skip to content

Serve SPA (Single Page Application) in django using whitenoise

License

Notifications You must be signed in to change notification settings

sandbox-pokhara/whitenoise-spa

Repository files navigation

whitenoise-spa

Serve SPA (Single Page Application) in django using whitenoise

Installation

You can install the package via pip:

pip install whitenoise-spa

Usage

  1. Edit your settings.py file and add whitenoise_spa.middleware.WhiteNoiseSPAMiddleware to the MIDDLEWARE list. The middleware should be placed directly after the Django SecurityMiddleware (if you are using it) and before all other middleware. This middleware replaces the whitenoise middleware.
    MIDDLEWARE = [
        # ...
        "django.middleware.security.SecurityMiddleware",
        "whitenoise_spa.middleware.WhiteNoiseSPAMiddleware",
        # ...
    ]
  2. Configure SPA root and urls.
    WHITENOISE_SPA_ROOT = BASE_DIR / "dist"
    WHITENOISE_SPA_URLS = ["/", "/login/", "/settings/"]

Limitations

  • Does not support wildcard urls for SPA urls.

License

This project is licensed under the terms of the MIT license.

About

Serve SPA (Single Page Application) in django using whitenoise

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages