This release is a pre-release and may not be stable for production use.
extension to [Django](https://www.djangoproject.com/) and
[SwampDragon](http://swampdragon.net/) with SwampDragon-auth and django-redis
which adds support for live updating Django template snippets on model changes.
Installation
------------
Install the latest version from pypi.python.org:
pip install SwampDragon-live
Install the development version by cloning the source from github.com:
pip install git+https://github.com/mback2k/swampdragon-live.git
Configuration
-------------
Add the package to your `INSTALLED_APPS`:
INSTALLED_APPS += (
'swampdragon',
'swampdragon_live',
)
Example
-------
Make sure to use django-redis as a Cache backend named 'swampdragon-live' or 'default':
CACHES = {
'swampdragon-live': {
'BACKEND': 'django_redis.cache.RedisCache',
'LOCATION': 'redis://localhost:6379/0',
'OPTIONS': {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
}
}
}
Make sure to add the following line to your Django settings file:
SWAMP_DRAGON_CONNECTION = ('swampdragon_auth.socketconnection.HttpDataConnection', '/data')
Load the required JavaScript template-tags within your Django template:
{% load swampdragon_tags %}
{% load swampdragon_live %}
Add the required JavaScript to your Django template:
{% swampdragon_settings %}
<script type="text/javascript" src="{{ STATIC_URL }}swampdragon/js/dist/swampdragon.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}swampdragon/js/live/swampdragon.live.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 'table' '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 'table-row' 'includes/row_cols.html' row=row perms=perms %}
Use the swampdragon_live 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="{{ swampdragon_live }}">...</tr>
You can check if your template is being live rendered by a content pusher by
using the context variable `is_swampdragon_live` like this:
{% if is_swampdragon_live %}
<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-2016 Marc Hoersken <info@marc-hoersken.de>
Metadata
Release files for SwampDragon-live 0.0.7a0
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 |
|---|---|---|---|---|
| SwampDragon-live-0.0.7a0.tar.gz | 8.0 kB | Without provenance | Details for SwampDragon-live-0.0.7a0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| SwampDragon_live-0.0.7a0-py2-none-any.whl | Python 2 | none | any | Details for SwampDragon_live-0.0.7a0-py2-none-any.whl |
Total release size: 18.6 kB
Release files / SwampDragon-live-0.0.7a0.tar.gz
| Download URL | SwampDragon-live-0.0.7a0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3839c67b6d16973bf9232bb5df1b48232d6d014c3c05943b6474a6db1a3fefda
|
|
BLAKE2b-256 checksum How to use checksums |
54f539c224f3221354c73fdda596857eb797fb20a4d3608b8f28cfa2401ca6b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / SwampDragon_live-0.0.7a0-py2-none-any.whl
| Download URL | SwampDragon_live-0.0.7a0-py2-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
7c13f2139bcd86f8a779855d77786a41fb66490af72e6311ec38b09ff0416e33
|
|
BLAKE2b-256 checksum How to use checksums |
9abd747d8139909ee69008549fe9cf0d6ba5d7450cb6ed07309eb9bcb327737b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for SwampDragon-live 0.0.7a0
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.