django-docutils ·

docutils (a.k.a. reStructuredText / rst / reST) support for Django.
Documentation: https://django-docutils.git-pull.com/
django-docutils turns off docutils features that are risky on the web — raw
HTML pass-through, file inclusion, and local docutils.conf lookup — and
filters unsafe link schemes from rendered output. That reduces risk; it does
not make untrusted markup safe. If people can submit their own
reStructuredText or Markdown to your site (comments, profiles, CMS fields),
read the Security topic
first.
Quickstart
Install django-docutils:
$ pip install django-docutils
Next, add django_docutils to your INSTALLED_APPS in your settings file:
INSTALLED_APPS = [
# ... your default apps,
"django_docutils"
]
Template tag
In your template:
{% load django_docutils %}
{% rst %}
Welcome
=======
Write `reStructuredText <https://docutils.sourceforge.io/rst.html>`_ with
links, **bold** text, and highlighted code:
.. code-block:: python
print("hello")
{% endrst %}
Template filter
In your template:
{% load django_docutils %}
{% filter rst %}
Welcome
=======
Write `reStructuredText <https://docutils.sourceforge.io/rst.html>`_ with
links, **bold** text, and highlighted code:
.. code-block:: python
print("hello")
{% endfilter %}
Template engine (class-based view)
You can also use a class-based view to render reStructuredText (reST).
If you want to use reStructuredText as a django template engine, INSTALLED_APPS isn't required,
instead you add this to your TEMPLATES variable in your settings:
TEMPLATES = [
# ... Other engines
{
"NAME": "docutils",
"BACKEND": "django_docutils.template.DocutilsTemplates",
"DIRS": [],
"APP_DIRS": True,
}
]
Now django will be able to scan for .rst files and process them. In your view:
from django_docutils.views import DocutilsView
class HomeView(DocutilsView):
template_name = "base.html"
rst_name = "home.rst"
Settings
# Optional, automatically maps roles, directives and transformers
DJANGO_DOCUTILS_LIB_RST = {
"docutils": {
"strip_comments": True,
"initial_header_level": 2,
},
"roles": {
"local": {
"gh": "django_docutils.lib.roles.github.github_role",
"twitter": "django_docutils.lib.roles.twitter.twitter_role",
"email": "django_docutils.lib.roles.email.email_role",
}
},
"directives": {
"code-block": "django_docutils.lib.directives.code.CodeBlock",
},
}
# Optional
DJANGO_DOCUTILS_LIB_TEXT = {
"uncapitalized_word_filters": ["project.my_module.my_capitalization_fn"]
}
For trusted static RST only — never for user-submitted content — docutils features that the default rendering disables can be re-enabled with an explicit opt-in (Security topic, docutils security guide):
DJANGO_DOCUTILS_LIB_RST = {
"allow_unsafe_docutils_settings": True,
"docutils": {
"raw_enabled": True,
"file_insertion_enabled": True,
},
}
More information
- Python 3.10+
- Django 5.2+
- Documentation · Quickstart · Security · FAQ
- New to the ecosystem? What is docutils? untangles docutils, reStructuredText, Sphinx, and Markdown.
- reStructuredText primer and quick reference from the docutils project.
Release files for django-docutils 0.31.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_docutils-0.31.1.tar.gz | 96.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_docutils-0.31.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 147.8 kB
Release files / django_docutils-0.31.1.tar.gz
| Download URL | django_docutils-0.31.1.tar.gz |
|---|---|
| Size | 96.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ac919696ac789360e2c327a8e545456a9d191bd72fdd0fb3a1c1a70a71ac274
|
|
BLAKE2b-256 checksum How to use checksums |
6b178325c0fe8ecf84e325ec9e2306a2edc9f6d609f2eea91243874dad0792b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency logRelease files / django_docutils-0.31.1-py3-none-any.whl
| Download URL | django_docutils-0.31.1-py3-none-any.whl |
|---|---|
| Size | 51.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20c9fd053a45fef0cd11af82a3dc55a03b4982d6bca2c4545c9756cf69a52c19
|
|
BLAKE2b-256 checksum How to use checksums |
02bf88458f66052e8d98522deedbd4a5b539aa51bbb5c64a1c6b0eb9891822c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 8, 2026.
Transparency log