Skip to main content

Django addon for a single page application with dynamically loaded pages

Project description


Django addon for a single page application with dynamically loaded pages


Use the python package manager pip to install djutils.

pip install djspa


Add 'djspa' to INSTALLED_APPS at the end


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

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' %}




This package is maintained by Manuel Stingl. For more information see

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for djspa, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size djspa-1.0.1-py3-none-any.whl (23.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size djspa-1.0.1.tar.gz (24.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page