{"id":27398039,"url":"https://github.com/metakermit/django-spa","last_synced_at":"2025-10-17T20:44:58.807Z","repository":{"id":19674831,"uuid":"87626134","full_name":"metakermit/django-spa","owner":"metakermit","description":"Simple Django configuration to serve a single-page app","archived":false,"fork":false,"pushed_at":"2022-12-08T03:20:07.000Z","size":167,"stargazers_count":99,"open_issues_count":16,"forks_count":19,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-18T01:01:47.602Z","etag":null,"topics":["angular","django","django-rest-framework","heroku","react","spa","whitenoise"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/metakermit.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-08T10:31:29.000Z","updated_at":"2025-02-17T20:49:19.000Z","dependencies_parsed_at":"2023-01-13T20:31:08.450Z","dependency_job_id":null,"html_url":"https://github.com/metakermit/django-spa","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metakermit%2Fdjango-spa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metakermit%2Fdjango-spa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metakermit%2Fdjango-spa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metakermit%2Fdjango-spa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metakermit","download_url":"https://codeload.github.com/metakermit/django-spa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248806777,"owners_count":21164566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","django","django-rest-framework","heroku","react","spa","whitenoise"],"created_at":"2025-04-14T01:28:45.909Z","updated_at":"2025-10-17T20:44:58.727Z","avatar_url":"https://github.com/metakermit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==========\ndjango-spa\n==========\n\n\n.. image:: https://badge.fury.io/py/django-spa.svg\n    :target: https://badge.fury.io/py/django-spa\n\n.. image:: https://travis-ci.org/metakermit/django-spa.svg?branch=master\n    :target: https://travis-ci.org/metakermit/django-spa\n\n.. image:: https://readthedocs.org/projects/django-spa/badge/?version=latest\n    :target: https://django-spa.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. image:: https://pyup.io/repos/github/metakermit/django-spa/shield.svg\n    :target: https://pyup.io/repos/github/metakermit/django-spa/\n    :alt: Updates\n\n.. image::  https://img.shields.io/badge/license-MIT-blue.svg\n    :target: https://raw.githubusercontent.com/metakermit/django-spa/master/LICENSE\n    :alt: GitHub license\n\n\nDjango package to serve a single-page app (SPA).\n\nThe following settings that make serving SPAs easier\nare handled in django-spa:\n\n* *index.html* served when ``/`` requested\n* all ``/static/…`` files served on ``/…`` as well\n* Django's urls still work (Django admin, templates, Django REST framework APIs)\n* everything else goes to ``/`` for frontend routing (e.g. `react-router`_)\n\nUsage\n------\n\nFor an example of using django-spa to serve a create-react-app frontend\nthat consumes a Django REST framework API, check out generator-django-rest_.\n\nAs part of setting up django-spa, you also need to set up WhiteNoise_,\nwhich we'll summarise here.\n\nFirst, add ``django-spa`` to your *requirements.txt*\nand ``pip install -r requirements.txt`` (or ``pipenv install django-spa``).\nWhitenoise is installed as a dependency, so no need to specify it extra.\n\nUpdate *settings.py* with the Whitenoise \u0026 django-spa middleware::\n\n    MIDDLEWARE = [\n        'django.middleware.security.SecurityMiddleware',\n        'whitenoise.middleware.WhiteNoiseMiddleware',\n        'spa.middleware.SPAMiddleware',\n        'django.contrib.sessions.middleware.SessionMiddleware',\n        'django.middleware.common.CommonMiddleware',\n        'django.middleware.csrf.CsrfViewMiddleware',\n        'django.contrib.auth.middleware.AuthenticationMiddleware',\n        'django.contrib.messages.middleware.MessageMiddleware',\n        'django.middleware.clickjacking.XFrameOptionsMiddleware',\n    ]\n\nDisable runserver's static file serving by adding ``runserver_nostatic``\nto the top of your INSTALLED_APPS list::\n\n    INSTALLED_APPS = [\n        'whitenoise.runserver_nostatic',\n        'django.contrib.staticfiles',\n        # ...\n    ]\n\nSet the django-spa static file storage::\n\n    STATICFILES_STORAGE = 'spa.storage.SPAStaticFilesStorage'\n\nYou should be good to go!\n\nCredits\n---------\n\nUsed some parts of the solution suggested in this `WhiteNoise issue`_\nfor serving index.html on ``/``.\nThis package was created with Cookiecutter_\nand the `audreyr/cookiecutter-pypackage`_ project template.\n\nLicense\n--------\n\nMIT_\n\n.. _Whitenoise: http://whitenoise.evans.io/en/stable/django.html\n.. _`Whitenoise issue`: https://github.com/evansd/whitenoise/issues/12\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n.. _`react-router`: https://reacttraining.com/react-router/\n.. _generator-django-rest: https://github.com/metakermit/generator-django-rest\n.. _MIT: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetakermit%2Fdjango-spa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetakermit%2Fdjango-spa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetakermit%2Fdjango-spa/lists"}