Template tag

Use rst() when reStructuredText source lives directly in a Django template block. The tag sends that block to the publisher helpers and returns HTML for Django to insert into the page.

See also

Quickstart

Setup

Add django_docutils to INSTALLED_APPS in your settings file:

INSTALLED_APPS = [
    # ... your default apps,
    "django_docutils"
]

Render a template block

Important

The {% rst %} tag uses locked-down docutils defaults. See Security before rendering user-authored RST or enabling trusted-content overrides.

In your HTML template:

{% load django_docutils %}
{% rst %}
hey
---

hi
##

A. hows
B. it

C. going
D. today

**hi**
*hi*
{% endrst %}

Output:

<main id="hey">
<h1 class="title is-1">hey</h1>
<p class="subtitle" id="hi">hi</p>
<ol class="upperalpha simple">
<li><p>hows</p></li>
<li><p>it</p></li>
<li><p>going</p></li>
<li><p>today</p></li>
</ol>
<p><strong>hi</strong>
<em>hi</em></p>
</main>

Explore the API