Simple Django configuration to serve a single-page app
Project description
django-spa
Simple Django configuration to serve a single-page app (SPA).
The following SPA settings are handled in django-spa:
everything not matched in Django’s urlpatterns goes to /
index.html served on /
all /static/… files served on /…
Usage
First set up WhiteNoise, as django-spa overrides some of its functionality.
Add django-spa to your requirements.txt:
-e git://github.com/metakermit/django-sap.git@public-url#egg=django-spa
Update settings.py with the django-spa middleware:
MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'spa.middleware.SPAMiddleware', ]
You should be good to go!
Credits
Used some parts of the solution suggested in this WhiteNoise issue for serving index.html on / . This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
License
History
0.1.0 (2017-04-08)
First release on PyPI.
Initial django-spa middleware.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_spa-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 341d94d88b7b6da621c8a35a18a17ea93b540a9bc0b277879713af1540bd3584 |
|
MD5 | 376c124e9bf5abd84b37dac620e1176e |
|
BLAKE2b-256 | 54a5eaa00260a39a7d9cbca54f42029b42a877354db7ad231f57da0ef4cb7799 |