This release is a pre-release and may not be stable for production use.
Django-Live-Templates is an extension to Django and Channels which adds support for live updating Django template snippets on model changes.
This project is based upon and a partial reimplementation to Channels of SwampDragon-live which was build using SwampDragon with SwampDragon-auth and django-redis.
Installation
Install the latest version from pypi.python.org:
pip install django-live-templates
Install the development version by cloning the source from github.com:
pip install git+https://github.com/mback2k/django-live-templates.git
Configuration
Add the package to your INSTALLED_APPS:
INSTALLED_APPS += (
'channels',
'django_live_templates',
)
Example
Make sure to use django-redis as a Cache backend named 'django-live-templates' or 'default':
CACHES = {
'django-live-templates': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://localhost:6379/0',
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
}
}
}
Load the required JavaScript template-tags within your Django template:
{% load django_live_template %}
Add the required JavaScript to your Django template:
<script type="text/javascript" src="{{ STATIC_URL }}js/django_live_template.js"></script>
Use the include_live template-tag instead of the default include template-tag, with rows being a Django database QuerySet to listen for added, changed, deleted instances:
{% include_live 'includes/table_body.html' rows=rows perms=perms %}
Use the include_live template-tag instead of the default include template-tag, with row being a single Django database Model instance to listen for changes:
{% include_live 'includes/row_cols.html' row=row perms=perms %}
Use the django_live_template variable within the included template to add the required classes to the root-tag of this template, e.g. the first tag-node:
<tr class="{{ django_live_template }}">...</tr>
You can check if your template is being live rendered by a content pusher by
using the context variable is_django_live_template like this:
{% if is_django_live_template %}
<style onload="alert('Hello World!');"></style>
{% endif %}
A real-world example can be found in the Django project WebGCal:
- https://github.com/mback2k/django-webgcal/blob/master/webgcal/apps/webgcal/templates/show_dashboard.html
- https://github.com/mback2k/django-webgcal/tree/master/webgcal/apps/webgcal/templates/includes
License
- Released under MIT License
- Copyright (c) 2015-2019 Marc Hoersken info@marc-hoersken.de
Metadata
Release files for django-live-templates 0.1a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-live-templates-0.1a0.tar.gz | 8.4 kB | Without provenance | Details for django-live-templates-0.1a0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_live_templates-0.1a0-py3-none-any.whl | Python 3 | none | any | Details for django_live_templates-0.1a0-py3-none-any.whl |
Total release size: 18.8 kB
Release files / django-live-templates-0.1a0.tar.gz
| Download URL | django-live-templates-0.1a0.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91db2247c26175f0b4ca2bc8a54a798ec296e8ae365064180d04ffd318a24f1d
|
|
BLAKE2b-256 checksum How to use checksums |
0be0a56e29be739d71249b1662ac49452a0c8f872bec462b5835e991495c1e22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
|
Release files / django_live_templates-0.1a0-py3-none-any.whl
| Download URL | django_live_templates-0.1a0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68c4a57431b6cce60b84a28b3f6f46629ff058e256f9aa4518d759b7abce98b3
|
|
BLAKE2b-256 checksum How to use checksums |
6e55286abb5e0fe8193a0c4185e061fb0e1ce1a04615d71c3d159bb06781d226
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
|
Security for django-live-templates 0.1a0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.