django-spa


Namedjango-spa JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/metakermit/django-spa
SummarySimple Django configuration to serve a single-page app
upload_time2017-09-01 16:10:16
maintainer
docs_urlNone
authorDražen Lučanin
requires_python
licenseMIT license
keywords django spa django-spa react angular yeoman heroku
VCS
bugtrack_url
requirements whitenoise
Travis-CI
coveralls test coverage No coveralls.
            ===============================
django-spa
===============================


.. image:: https://img.shields.io/pypi/v/django-spa.svg
        :target: https://pypi.python.org/pypi/django-spa

.. image:: https://img.shields.io/travis/metakermit/django-spa.svg
        :target: https://travis-ci.org/metakermit/django-spa

.. image:: https://readthedocs.org/projects/django-spa/badge/?version=latest
        :target: https://django-spa.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status

.. image:: https://pyup.io/repos/github/metakermit/django-spa/shield.svg
     :target: https://pyup.io/repos/github/metakermit/django-spa/
     :alt: Updates


Simple Django configuration to serve a single-page app (SPA).

The following SPA settings are handled in django-spa:

* index.html served on ``/``
* all ``/static/...`` files served on ``/...``
* Django's urls still work (Django admin, templates, Django REST framework APIs)
* everything else goes to ``/`` for frontend routing (e.g. `react-router`_)

Usage
------

First set up WhiteNoise_, as django-spa overrides some of its functionality.

Add django-spa to your *requirements.txt*::

    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',
    ]

Use the django-spa static file storage::

    STATICFILES_STORAGE = 'spa.storage.SPAStaticFilesStorage'

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
--------

MIT_

.. _Whitenoise: https://github.com/evansd/whitenoise/
.. _`Whitenoise issue`: https://github.com/evansd/whitenoise/issues/12
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _`react-router`: https://reacttraining.com/react-router/
.. _MIT: LICENSE


=======
History
=======

0.2.0 (2017-09-01)
------------------

* Fix #3


0.1.1 (2017-04-08)
------------------

* Metadata fixes.


0.1.0 (2017-04-08)
------------------

* First release on PyPI.
* Initial django-spa middleware.



            

Raw data

            {
    "_id": null,
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "cheesecake_code_kwalitee_id": null,
    "keywords": "django spa django-spa react angular yeoman heroku",
    "upload_time": "2017-09-01 16:10:16",
    "requirements": [
        {
            "name": "whitenoise",
            "specs": [
                [
                    "==",
                    "3.2.2"
                ]
            ]
        }
    ],
    "author": "Dra\u017een Lu\u010danin",
    "home_page": "https://github.com/metakermit/django-spa",
    "github_user": "metakermit",
    "download_url": "https://pypi.python.org/packages/9f/0d/da4efc364636f79a0f0f5478c8e42c004ce2810a15d2590cf5719ba56c41/django-spa-0.2.0.tar.gz",
    "platform": "",
    "version": "0.2.0",
    "cheesecake_documentation_id": null,
    "description": "===============================\ndjango-spa\n===============================\n\n\n.. image:: https://img.shields.io/pypi/v/django-spa.svg\n        :target: https://pypi.python.org/pypi/django-spa\n\n.. image:: https://img.shields.io/travis/metakermit/django-spa.svg\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\nSimple Django configuration to serve a single-page app (SPA).\n\nThe following SPA settings are handled in django-spa:\n\n* index.html served on ``/``\n* all ``/static/...`` files served on ``/...``\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\nFirst set up WhiteNoise_, as django-spa overrides some of its functionality.\n\nAdd django-spa to your *requirements.txt*::\n\n    django-spa\n\nUpdate *settings.py* with the django-spa middleware::\n\n    MIDDLEWARE = [\n        'django.middleware.security.SecurityMiddleware',\n        'whitenoise.middleware.WhiteNoiseMiddleware',\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        'spa.middleware.SPAMiddleware',\n    ]\n\nUse 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: https://github.com/evansd/whitenoise/\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.. _MIT: LICENSE\n\n\n=======\nHistory\n=======\n\n0.2.0 (2017-09-01)\n------------------\n\n* Fix #3\n\n\n0.1.1 (2017-04-08)\n------------------\n\n* Metadata fixes.\n\n\n0.1.0 (2017-04-08)\n------------------\n\n* First release on PyPI.\n* Initial django-spa middleware.\n\n\n",
    "tox": true,
    "lcname": "django-spa",
    "name": "django-spa",
    "github": true,
    "coveralls": false,
    "bugtrack_url": null,
    "license": "MIT license",
    "travis_ci": true,
    "github_project": "django-spa",
    "summary": "Simple Django configuration to serve a single-page app",
    "split_keywords": [
        "django",
        "spa",
        "django-spa",
        "react",
        "angular",
        "yeoman",
        "heroku"
    ],
    "author_email": "kermit666@gmail.com",
    "urls": [
        {
            "has_sig": false,
            "upload_time": "2017-09-01T16:10:16",
            "comment_text": "",
            "python_version": "source",
            "url": "https://pypi.python.org/packages/9f/0d/da4efc364636f79a0f0f5478c8e42c004ce2810a15d2590cf5719ba56c41/django-spa-0.2.0.tar.gz",
            "md5_digest": "bcb5afc5aefc545d2c8c3914ec29e3d9",
            "downloads": 0,
            "filename": "django-spa-0.2.0.tar.gz",
            "packagetype": "sdist",
            "path": "9f/0d/da4efc364636f79a0f0f5478c8e42c004ce2810a15d2590cf5719ba56c41/django-spa-0.2.0.tar.gz",
            "size": 14636
        },
        {
            "has_sig": false,
            "upload_time": "2017-09-01T16:10:15",
            "comment_text": "",
            "python_version": "py2.py3",
            "url": "https://pypi.python.org/packages/7f/96/1b6ba9d3e2d81659870e3d26a64c3b36ea4ac05d757ee2af3a825bcd49d0/django_spa-0.2.0-py2.py3-none-any.whl",
            "md5_digest": "a54cbb3bb1ee8e602478453170448438",
            "downloads": 0,
            "filename": "django_spa-0.2.0-py2.py3-none-any.whl",
            "packagetype": "bdist_wheel",
            "path": "7f/96/1b6ba9d3e2d81659870e3d26a64c3b36ea4ac05d757ee2af3a825bcd49d0/django_spa-0.2.0-py2.py3-none-any.whl",
            "size": 7320
        }
    ],
    "cheesecake_installability_id": null
}
        
Elapsed time: 0.07522s