Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Django serve SPA

Serve SPAs with Django

Quick start

pip install django-serve-spa

Build your SPA and copy the contents of the build into SPA_ROOT (e.g. path/to/django/spa/).

# settings.py
SPA_ROOT = BASE_DIR / 'spa'  # where the built SPA code will live
SPA_URL = ''  # To serve from /

# urls.py
from kaos_spa import settings as spa_settings

urlpatterns += [
    path(spa_settings.SPA_URL, include('kaos_spa.urls')),
]

Runserver, and visit SPA_URL (/ by default). Your SPA will show up.

Notes

django-serve-spa is meant to be used for development and isn't recommended for production use. For production, serve the SPA on its own using tools like npm serve.

django-serve-spa is mostly tested with create-react-app apps, but in theory should work with any SPA.

Utility scripts

django-serve-spa comes bundled with some utility scripts that makes building and copying your SPA project much more convenient.

build-spa

Build your SPA and put it in your django project.

Set the following environment variables

# required
SPA_SRC_DIR=/path/to/your/spa/
SPA_IN_DJANGO_DIR=/path/to/your/django/project/spa/  # what the SPA_ROOT django setting refers to

# optional
SPA_URL  # If you are not serving on /
SPA_BUILD_CMD="npm run build"
SPA_BUILD_DIR_PATH='build/'  # Where the build command builds the app in its src directory

run

build-spa

It'll build your SPA and put it in the right folder in your django project.

cm-spa-build

Commits the new build into Git with commit message from arg. If no arg is supplied, commit message defaults to "New SPA build".

Set the following environment variables

# required
SPA_IN_DJANGO_DIR=/path/to/your/django/project/spa/  # what the SPA_ROOT django setting refers to

run

cm-spa-build

Development and Testing

IDE Setup

Add the example directory to the PYTHONPATH in your IDE to avoid seeing import warnings in the tests modules. If you are using PyCharm, this is already set up.

Running the Tests

Install requirements

pip install -r requirements.txt

For local environment

pytest

For all supported environments

tox

Metadata

Release files for django-serve-spa 0.1.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-serve-spa 0.1.0rc1
File Size Uploaded Provenance
django-serve-spa-0.1.0rc1.tar.gz 5.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-serve-spa 0.1.0rc1
File Interpreter ABI Platform
django_serve_spa-0.1.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / django-serve-spa-0.1.0rc1.tar.gz

Download URL django-serve-spa-0.1.0rc1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
19badd358d884b3684340242ef8abdbbd0ee3c74423050f912305d6e92e4a033
BLAKE2b-256 checksum
How to use checksums
e76f821fffe57559ae752054f2006afc7e0c907b37ac9b0c27542c12dd759b79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.7

Release files / django_serve_spa-0.1.0rc1-py3-none-any.whl

Download URL django_serve_spa-0.1.0rc1-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1379629e7128529ca964de08413db3746e711ea4ec3f91599f7b36001b920a9
BLAKE2b-256 checksum
How to use checksums
47f5cdb6124154cfffbe8be8f0250a7c0cf0ab7452499b1e2466349071d589c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.7

Security for django-serve-spa 0.1.0rc1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page