Django Pygmentify is a Django template tag application to highlight code with Pygments.
It is an alternative to Django Pygments, which hasn't been updated in several years.
$ pip install django-pygmentify
Add to settings.py
.
INSTALLED_APPS = [
# ...
'pygmentify',
]
{% load pygmentify_tags %}
<link rel="stylesheet" href="{% pygmentify_css %}">
{% pygmentify %}
<pre class="python">
print('Hello, world!')
</pre>
{% endpygmentify %}
Result:
<link rel="stylesheet" href="/static/pygmentify/css/default.min.css">
<div class="highlight"><pre class="python"><span></span><span class="k">print</span><span class="p">(</span><span class="s2">"Hello, world!"</span><span class="p">)</span>
</pre></div>