Django class based views for templates stored in a database.
Project description
Serve your single page Javascript applications from Django.
Documentation
The full documentation is at https://django-database-views.readthedocs.io.
Requirements
Django > 1.8
A database engine such as MySQL
Quickstart
Install django-database-views using pip:
pip install django-database-views
Add it to your installed apps:
INSTALLED_APPS = ( ... 'database_views.apps.DatabaseViewsConfig', ... )
Create a model to store versions for your index template in your app’s models.py:
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 views.py 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): app_name = 'main' model = IndexTemplate response_class = CachedTemplateResponse
Add a route for your index page view in your project’s urls.py 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.
Features
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
Credits
Tools used in rendering this package:
History
0.1.0 (2017-03-10)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-database-views-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26a8d2d988c98ec195b089d09d7c7fefaec65340961f614801b0b9d03b4b0935 |
|
MD5 | bc0fdae27baa703604c21d873ef61987 |
|
BLAKE2b-256 | 02fa480f3d5950661626affef8ab6818b2758ac7a47708fff3c8f56a48e601cf |
Hashes for django_database_views-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b3bffdfcb29b352d9a8f9e42cd8c6f066ea8541c224784ca20eaefdd9f45d7e |
|
MD5 | 56bf507957e0a9398eae5fe9d9bdbcd9 |
|
BLAKE2b-256 | 0c63ee12709f6f233afc861bb0f4eb429cb0b53ae41eaaa0e360713809b513f4 |