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",
}
},
}
# Optional
DJANGO_DOCUTILS_LIB_TEXT = {
"uncapitalized_word_filters": ["project.my_module.my_capitalization_fn"]
}
More information
- Python 3.8+
- Django 3.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
File details
Details for the file django_docutils-0.19.0.tar.gz
.
File metadata
- Download URL: django_docutils-0.19.0.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ad4ff5a7481f42d27e9ed56d72a6677753111e1e87c4bc5f0d8fefe8b1b1fb9 |
|
MD5 | a545b3120e7422860dedde1e40be83b4 |
|
BLAKE2b-256 | fdd11068aabb9a105cd075a3739779e78f62c31cb1db03027de0da4cb5cf330b |
Provenance
File details
Details for the file django_docutils-0.19.0-py3-none-any.whl
.
File metadata
- Download URL: django_docutils-0.19.0-py3-none-any.whl
- Upload date:
- Size: 44.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9080a3b76fce37099c437aaf287237b43a506a9d54ebc2a3625f8b42438d584b |
|
MD5 | b16dd015f9f0f75fb726f9983bd2e723 |
|
BLAKE2b-256 | b8071e71ab24e25a2a650a12f976dab2d79040bb1a61be87bd145f3fded5cf0a |