Docutils (a.k.a. reStructuredText, reST, RST) support for django.
Project description
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 4.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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_docutils-0.30.0.tar.gz.
File metadata
- Download URL: django_docutils-0.30.0.tar.gz
- Upload date:
- Size: 198.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6964e3defd9bd441c72f5a3514cafdec1a1c16e68bce768fa75784d6ac01d931
|
|
| MD5 |
4f770a688794978fbb658fc0476f6d01
|
|
| BLAKE2b-256 |
03577a1e9cab685343dae9503d67e444d30b9ef08a60e4725728c04071c00635
|
Provenance
The following attestation bundles were made for django_docutils-0.30.0.tar.gz:
Publisher:
tests.yml on tony/django-docutils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_docutils-0.30.0.tar.gz -
Subject digest:
6964e3defd9bd441c72f5a3514cafdec1a1c16e68bce768fa75784d6ac01d931 - Sigstore transparency entry: 1749712571
- Sigstore integration time:
-
Permalink:
tony/django-docutils@d9cb455d7eee974ca6a0fd71d55a4753de98a873 -
Branch / Tag:
refs/tags/0.30.0 - Owner: https://github.com/tony
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
tests.yml@d9cb455d7eee974ca6a0fd71d55a4753de98a873 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_docutils-0.30.0-py3-none-any.whl.
File metadata
- Download URL: django_docutils-0.30.0-py3-none-any.whl
- Upload date:
- Size: 50.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7af9ad6915196abf18afb1acd82f2a64944c4ab1d9f384598f1cc0392fea39a3
|
|
| MD5 |
fb829df4d09da580bd229ab5ace2e474
|
|
| BLAKE2b-256 |
5331317cea3611425ae94ec758bc93d0aa2fc4188633eae5de0756dbfd516620
|
Provenance
The following attestation bundles were made for django_docutils-0.30.0-py3-none-any.whl:
Publisher:
tests.yml on tony/django-docutils
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_docutils-0.30.0-py3-none-any.whl -
Subject digest:
7af9ad6915196abf18afb1acd82f2a64944c4ab1d9f384598f1cc0392fea39a3 - Sigstore transparency entry: 1749712921
- Sigstore integration time:
-
Permalink:
tony/django-docutils@d9cb455d7eee974ca6a0fd71d55a4753de98a873 -
Branch / Tag:
refs/tags/0.30.0 - Owner: https://github.com/tony
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
tests.yml@d9cb455d7eee974ca6a0fd71d55a4753de98a873 -
Trigger Event:
push
-
Statement type: