Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time



Join the chat at See latest build status at Coverage

Intuitive text editing for humans using Django.

The django-text toolbar

This project is in early development, please test it out and report any bugs!


Install the package with pip.

$ pip install django-text

Add text to your installed packages.


    # ...

Add text.middleware.TextMiddleware and 'text.middleware.ToolbarMiddleware' to your middleware classes.


    # ...

Make sure these context processors are installed, they come with Django.


    # ...

Append text.urls to your urlpatterns in


from django.conf.urls import patterns, include, url

from text.urls import urlpatterns as django_text_patterns

urlpatterns = patterns('',
    url(r'^django_text/', include(django_text_patterns, namespace='django_text')),

Run migrate.

$ python migrate


The text tag

Add editable tags to your templates.

{% load text %}

<h1>{% text "header" "My Header" %}</h1>

<div class="content">
    {% text "text_body" %}

The text tag takes a default text as the second argument. If no default text is passed, the name of the text node (i.e. the first argument) will be used if there is no corresponding text node in the database.

The blocktext tag

You can also use the blocktext tag that let's you wrap content to use as the default text.

{% load text %}

<div class="content">
        {% blocktext "header" %}
            Read My Awesome Text
        {% endblocktext %}

    {% blocktext "content" %}
        Put your default text here!
    {% endblocktext %}

The blocktext tags works with translation tags inside of it. So if you already have a translated site, you can wrap your content with this tag and only add text nodes for some of the languages that you support.

Specifying content type

Both the text and the blocktext tags support specifying the content type of its default text. The choices are "html", "markdown" and "text" which is the default.

{% text "html_node" "<h1>Hello World!</h1>" "html" %}

{% blocktext "markdown_node" "markdown" %}
# Hello there,

I can have markdown in my templates!
{% endblocktext %}

If content type is not provided both will default to text.

Disable instant updating

By default the templatetags will wrap all text nodes with a span element to enable "instant updating", if TEXT_TOOLBAR_INSTANT_UPDATE is set to True. Sometimes this can cause trouble, for instance when you want to have editable texts inside <title> or <meta> elements.

You can disable instant updating on per-node basis by setting the templatetag keyword argument instant_update to False:

<title>{% text "title" "Welcome!" instant_update=False %}</title>

    {% blocktext "block_title" instant_update=False %}
    Welcome one, welcome all!
    {% endblocktext %}

Content editing

The toolbar allows you to edit texts directly on your pages if you're signed in as staff and have the permission 'text.change_text' or if you're signed is as a superuser.

Missing text nodes will be added to the database automatically when their template tags are rendered.



Default: True

Set to false to disable django-text from adding missing text nodes to the database.


Default: True

Set to false to disable the toolbar interface.


Default: 'djtext_form'

This is passed to the toolbar form and can be changed to avoid name conflicts.


Default: True

Set to false to disable instant updating of the DOM when saving texts in the toolbar.


Default: ('<span data-text-name="{0}" class="{1}">', '</span>')

A tuple of two that gets wrapped around texts in the template to enable instant updating.


Default: 'dj_text_inline_wrapper'

Change this to change the class of the element that gets wrapped around texts.


Contribution is very welcome. Use issues to report bugs and propose features. For pull requests to be accepted they need to be well tested.

Running tests

Install test dependencies.

$ brew install phantomjs
$ pip install -r test-requirements.txt

Run tests.

$ make test

Run tests with coverage.

$ make test-coverage


Copyright (c) 2015-2017 Anton Agestam. django-text is released under the MIT license. See the LICENSE file for more information and licenses for bundled code.

You can’t perform that action at this time.