Skip to main content

Keyed blocks of text or html content for use in your Django templates

Project description

Django Text Chunks

Insert blocks of text anywhere in in your template


Install package using pip

$ pip install django-textchunks

Basic usage

Add the textchunks application to INSTALLED_APPS in your settings file (usually


Sync database with ./ migrate. After that, add textchunks using django admin interface and use them on your templates:

{% load textchunks %}

    {% textchunk "google_analytics" %}
    <h1>Blah blah blah</h1>
    <div id="sidebar">
    <div id="left">
        {% textchunk "home_page_left" %}
    <div id="right">
        {% textchunk "home_page_right" %}

Advanced usage

There are two template tags available: textchunk and textchunk_plain. Text displayed with textchunk is not escaped, any html and javascript is rendered or executed. textchunk_plain tag uses from django.utils.html.escape to escape it’s content, so it’s safe to render user-entered text.

textchunk tag uses django Template object to render data and has access to template context. So, text

<span>{{ request.user.username }}</span>

for user with username as agentsmith will be rendered as


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-textchunks, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django_textchunks-0.1.1-py2.py3-none-any.whl (6.7 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-textchunks-0.1.1.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page