Skip to main content

http://github.com/idlesign/django-siteblocks

https://img.shields.io/pypi/v/django-siteblocks.svg https://img.shields.io/pypi/l/django-siteblocks.svg https://img.shields.io/coveralls/idlesign/django-siteblocks/master.svg https://img.shields.io/travis/idlesign/django-siteblocks/master.svg

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

http://django-siteblocks.readthedocs.org/

Release files for django-siteblocks 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-siteblocks 1.2.1
File Size Uploaded
django-siteblocks-1.2.1.tar.gz 20.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-siteblocks 1.2.1
File Interpreter ABI Platform
django_siteblocks-1.2.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 41.0 kB

Release files / django-siteblocks-1.2.1.tar.gz

Download URL django-siteblocks-1.2.1.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e6c7dd579a43cad0120513a7c12f0007050fd5abf1b2d7e844fc7fa63cda83da
BLAKE2b-256 checksum
How to use checksums
ba692c950e8c44675297af6230eeb21a19bd09e5e204151f11b433de6ad3f889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/2.7

Release files / django_siteblocks-1.2.1-py2.py3-none-any.whl

Download URL django_siteblocks-1.2.1-py2.py3-none-any.whl
Size 20.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4bfb963affc3ca727f318f5ca9db4297732ca74086be4982f00772946c7e09fd
BLAKE2b-256 checksum
How to use checksums
973833952b5edf2b9164420ab67626a03d0ee1ead724eb62ca0be708f52a0168
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/2.7

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page