How to use Django template tags in a Jinja2 template?

There are some ready-made Django packages that offer template tags, and I would like to use them in my project, despite the fact that it uses Jinja2.

I saw some workarounds that allow other template engines to use Django tags. These include creating a mini-template in a string and passing it to the Django template processor along with the current context. Here are two examples of what I'm saying: Mako templates using Django template templates and Jinja2 templates using Django template tags .

I am wondering if there is a less hacky solution.

+4
source share
1 answer

how about moving a problem to Python scope? and import one Python function into another as follows:

in your_jinja_templatetags.py

 from some_django_templatetags import somefilter as base_somefilter @library.filter def somefilter(value): return base_somefilter(value) 
0
source

All Articles