Skip to main content

Django Markdownify - A Django Markdown filter

PyPi Downloads License Documentation Status Version

Django Markdownify is a template filter to convert Markdown to HTML in Django. Markdown is converted to HTML and sanitized.

Read the full documentation on Read the docs or check out the package on pypi.

[!WARNING]
The old settings are removed in release 0.9.4! Please update to the new settings as soon as possible.

Usage

Load the tag inside your template:

{% load markdownify %}

Then you can change markdown to html as follows:

{{ 'text'|markdownify }}

or

{{ somevariable|markdownify }}

Example

{% load markdownify %}
{{'Some *test* [link](#)'|markdownify }}

Is transformed to:

<p>
  Some <em>test</em> <a href="#">link</a>
</p>

The filter is a wrapper around Markdown and Bleach and as such supports their settings. It is possible to define multiple settings for multiple usecases.

For example:

# settings.py

MARKDOWNIFY = {
  "default": {
     "WHITELIST_TAGS": ["a", "p", "h1", ]
  },

  "alternative": {
     "WHITELIST_TAGS": ["a", "p", ],
     "MARKDOWN_EXTENSIONS": ["markdown.extensions.fenced_code", ]
  }
}

And in your templates:

<!-- page1.html -->
{{ mytext|markdownify }} <!-- Uses your default settings -->

<!-- page2.html -->
{{ mytext|markdownify:"alternative" }} <!-- Uses your alternative settings -->

Documentation

Read the full documentation on Read the docs.

Credits

This filter is a slightly richer and packaged version of the snippet: using-markdown-django-17.

Release files for django-markdownify 0.9.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-markdownify 0.9.7
File Size Uploaded
django_markdownify-0.9.7.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-markdownify 0.9.7
File Interpreter ABI Platform
django_markdownify-0.9.7-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 kB

Release files / django_markdownify-0.9.7.tar.gz

Download URL django_markdownify-0.9.7.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2e59dfd445ad6362288f7bc1574e45d8356848463e261b878fd70df6a272c47f
BLAKE2b-256 checksum
How to use checksums
dbae2ecbac028f470ed78b8826413495d5ea60c9d53d7af000729ff3a7663ff8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / django_markdownify-0.9.7-py3-none-any.whl

Download URL django_markdownify-0.9.7-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca3a6361f952d1c1b661c13229f69219a36e745358aa0f377212aef8f09e4cf3
BLAKE2b-256 checksum
How to use checksums
34b99b1a28f605ad75fa7e4588f51661eb3c7c5feb5ad23e985761e9a14d01c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.9.7 This release

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

1 release file

0.3.0

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page