Reusable application for Django introducing URL-dependent static and dynamic data blocks
Project description
http://github.com/idlesign/django-siteblocks
What’s that
django-siteblocks is a reusable application for Django to build blocks of static or dynamic data that could be used in templates.
It allows you to describe data that doesn’t clearly belong to any application in your project in terms of static or dynamic blocks, that could be rendered in certain places on site pages. These blocks are addressed in templates by their aliases.
The following siteblock types are supported:
Static
Those are defined using Django Admin contrib and are linked to certain URLs.
This allows different siteblock contents on different URLs. Just go to admin and add some blocks.
Dynamic
Those are ordinary Python functions registered as siteblocks returning contents.
This allows complex logic to build siteblock contents. Let’s make a block with a random quote from Pratchett:
from random import choice
from siteblocks.siteblocksapp import register_dynamic_block
def get_quote(**kwargs):
quotes = [
'Early to rise, early to bed, makes a man healthy, wealthy and dead.',
'The duke had a mind that ticked like a clock and, like a clock, it regularly went cuckoo.',
'Speak softly and employ a huge man with a crowbar.',
]
return choice(quotes)
register_dynamic_block('quote', get_quote)
Block rendering
Use siteblocks tag to render block contents where you need it.
{% load siteblocks %}
<div class="quote">
{% siteblock "quote" %}
</div>
Documentation
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
File details
Details for the file django-siteblocks-1.2.1.tar.gz
.
File metadata
- Download URL: django-siteblocks-1.2.1.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/2.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6c7dd579a43cad0120513a7c12f0007050fd5abf1b2d7e844fc7fa63cda83da |
|
MD5 | 409dcfb66d79bec712ee1c44c7a76af0 |
|
BLAKE2b-256 | ba692c950e8c44675297af6230eeb21a19bd09e5e204151f11b433de6ad3f889 |
File details
Details for the file django_siteblocks-1.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: django_siteblocks-1.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/2.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bfb963affc3ca727f318f5ca9db4297732ca74086be4982f00772946c7e09fd |
|
MD5 | eea9947090ee2474e9682f2e30f272e1 |
|
BLAKE2b-256 | 973833952b5edf2b9164420ab67626a03d0ee1ead724eb62ca0be708f52a0168 |