Skip to main content

Django class based views for templates stored in a database.

Project description

Serve your single page Javascript applications from Django.


The full documentation is at


  • Django > 1.8
  • A database engine such as MySQL


Install django-database-views using pip:

pip install django-database-views

Add it to your installed apps:


Create a model to store versions for your index template in your app’s

from database_views.models import AbstractTemplate

class IndexTemplate(AbstractTemplate):

    class Meta:
        db_table = 'your_table_name' # For example 'index_template'.

Create a class-based view for your single page app in your app’s and assign your model to its model property:

from database_views.views import DatabaseTemplateView
from database_views.views import CachedTemplateResponse
from myapp.models import IndexTemplate

class IndexView(DatabaseTemplateView):
    model = IndexTemplate
    response_class = CachedTemplateResponse

Add a route for your index page view in your project’s file:

from myapp.views import IndexView

urlpatterns = [
    url(r'^$', IndexView.as_view())

That’s it!! Go to your new route and you should see your single page app’s index template served. Please ensure that you configure the serving of your app’s static assets properly.


  • Easily serve your single page javascript applications from Django.
  • Optionally cache your templates for a configurable amount of time.
  • Works with ember-cli-deploy and more specifically with ember-cli-deploy-mysql.

Running Tests

To run tests use the following commands from the root of this project:

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install -r requirements_test.txt
(myenv) $ py.test


Tools used in rendering this package:


0.1.0 (2017-03-10)

  • First release on PyPI.

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 django-database-views, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django_database_views-0.1.1-py2.py3-none-any.whl (7.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-database-views-0.1.1.tar.gz (7.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page