Skip to main content

Django addon for a single page application with dynamically loaded pages

Project description

djspa

Django addon for a single page application with dynamically loaded pages

Installation

Use the python package manager pip to install djutils.

pip install djspa

Usage

Add 'djspa' to INSTALLED_APPS at the end

INSTALLED_APPS = [
    ...
    'djspa',
]

Mark your BasePage (Template Class from that all other templates inherit) with the @set_baseview decorator of djspa

from django.views import generic
from djspa import set_baseview

@set_baseview
class BaseView(generic.TemplateView):
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['my_global_template_variable'] = 42
        return context

Define your dynamic pages by a class, which inherits from your BaseView and the PageMixin. You have to set at least the name property, which is the name of the template and also the url.

Import the djspa urlpatterns after you defined all views from djspa.urls import urlpatterns # pylint:disable=C0411; urlpatterns of djspa MUST be loaded after all view definitions

You have to define at least the index page, otherwise you get an endless redirect loop.

from djspa import PageMixin

class Index(BaseView, PageMixin):
    name = 'index'

Include the pages snippet in your index page template

{% include 'djspa_pages.html' %}

License

GNU GPLv3, see LICENSE

Maintainer

This package is maintained by Manuel Stingl. For more information see https://opensource.voltane.eu

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

djspa-1.0.1.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

djspa-1.0.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file djspa-1.0.1.tar.gz.

File metadata

  • Download URL: djspa-1.0.1.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.3

File hashes

Hashes for djspa-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f18a3713605106b4ed615969d34c89703d3e65273fdba01104358c62e5b3e068
MD5 42dcd3ab4e4367bac21b4922b8da1479
BLAKE2b-256 a68d4bd1ff3eb96ac6a69e936f40dc0521fd8ee39a08aba4ebd2cc8b89ea33d0

See more details on using hashes here.

File details

Details for the file djspa-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: djspa-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.3

File hashes

Hashes for djspa-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c5a661a002d076baf4bb5d61c9e9b8c12912561d3ea29802a45e29dc5cd4654
MD5 99257e943e212c40a3b08b08d655ba64
BLAKE2b-256 2ab2d07c74bda30e6ede0583ef1d91f87e8cc0949b6ca5f76aed96cb07f2cc10

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page