Docutils (a.k.a. reStructuredText, reST, RST) support for django.
Project description
django-docutils ·

docutils (a.k.a. reStructuredText / rst / reST) support for Django.
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 %}
# hey
# how's it going
A. hows
B. it
C. going
D. today
**hi**
*hi*
{% endrst %}
Template filter
In your template:
{% load django_docutils %}
{% filter rst %}
# hey
# how's it going
A. hows
B. it
C. going
D. today
**hi**
*hi*
{% 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": {
"raw_enabled": True,
"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"]
}
More information
- Python 3.10+
- Django 4.2+
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.29.0.tar.gz.
File metadata
- Download URL: django_docutils-0.29.0.tar.gz
- Upload date:
- Size: 153.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1beaace08ccac7b5b8ad2149474975afaa07493e0780a23aadbf8399669e263a
|
|
| MD5 |
18ff876c5cba16b37269cdcc3e1bf40c
|
|
| BLAKE2b-256 |
72bf2ac512994288ca201616a75bb87c1ed682e13af1d08c0b8b23fabb85888c
|
File details
Details for the file django_docutils-0.29.0-py3-none-any.whl.
File metadata
- Download URL: django_docutils-0.29.0-py3-none-any.whl
- Upload date:
- Size: 45.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2854db795482dcc75ab8ec7baa9db8bc4481ea025c3ba0db7d8bb2b549f4ea4d
|
|
| MD5 |
5816ffb0a023ccb813b136fca7851d3d
|
|
| BLAKE2b-256 |
e0eac39440db82fbfae0718af0d8ef3b79aaace77c5148132050358225f2e0f5
|