Does PyCharm support Jinja2?
Solution 1
In the pro edition, these template languages:
- Jinja2
- Django
- Mako
are supported. You can configure the template language in the project's settings:
The community edition may lack certain template languages.
Solution 2
I think it's worth to mention that PyCharm Community edition does not support Jinja2, Mako and Django. It's available only in PyCharm Professional.
See comparison of the two.
Solution 3
Yes pro edition from pycharm does support Jinja2 to enable it go here
From File open Settings and search for python template under Languages & Frameworks Select Python Template Languages from there Click HTML And Select Jinja2 as Template Language.
please see the image for better understanding.
Solution 4
If you are using .jinja
extension instead of .jinja2
, it won't work, templates are not highlighted.
You have to add the file extension to the filetypes section.
- Preferences > General > Filetypes
- Scroll to Jinja 2 Template
- Register new pattern by clicking +, add
*.jinja
Related videos on Youtube
k0pernikus
I am Philipp Kretzschmar, a backend developer from Hamburg working at Demvsystem. You can find me on github. Or twitter. My main weapons of choice are: php TypeScript (I don't want to write plain JavaScript anymore) and nodejs I play around with: Java python rust I used to write some scala, but for now I don't want to go there anymore. I feel most comfortable on a unix-like system featuring a powerful bash. (This excludes MacOS.) I love to code within JetBrains's flavored IDEs, e.g. IntelliJ, PhpStorm, WebStorm and using the IdeaVim plugin and having a docker-compose stack to develop on.
Updated on July 05, 2022Comments
-
k0pernikus almost 2 years
A bottle project of mine uses Jinja2. PyCharm does not automatically recognize it and shows such lines as errors. Is there a way to make Jinja2 work?
-
Kenji Noguchi over 10 yearsI got "Expected }}" warning for every function calls such as {{ func('hello word') }}. How can I fix it?
-
okigan over 10 yearsAlso worth to mention that (even as of PyCharm 3.1) Debugging Jinja and Mako templates is not supported [even in pro edition]. jetbrains.com/pycharm/webhelp/debugging-django-templates.html
-
Spooner about 9 yearsYou need to apply the change, otherwise it will go back to assuming django formatting.
-
Chris Mueller about 8 yearsThis is very worth mentioning. I just spent 5 minutes looking through the project settings (based on the first answer) before I read this answer.
-
Noumenon about 8 years"Out of the box" is not correct for PyCharm Community edition -- see below. (I tried to edit this information into the answer, but it got rejected 3-2.)
-
k0pernikus about 8 years@Noumenon I've added the information to my own answer, as I think that clarifies it a bit more. The reject was, in principle, fine by stackoverflow standard (changes intent of the author) and edits are not necessarily there to correct false answers, for that one should either downvote the answer and create your own and write a comment. Yours was an edge-case as I do think it would have improved my answer significantly.
-
Noumenon about 8 yearsYour comment would have made a great, educational rejection message for my edit. "Doesn't improve the answer even a little" tends to get my hackles up. Thank you.
-
k0pernikus over 7 yearsI am a bit confused as to where the difference is from my answer: stackoverflow.com/questions/15750551/…
-
Semicolon over 7 years@k0pernikus this is the dark theme answer :)
-
José Tomás Tocino over 7 yearsThis has newbie-friendly steps, plus one for that!
-
Harrichael almost 7 yearsThis answer is the one that helped me, because of newbie friendly steps.
-
Ayyoub almost 7 yearsthanks guys, anything to give back for this awesome community. ! . :)
-
Jean-Marc Amon over 5 yearsThanks,it's helps me a lot
-
t3chb0t over 2 yearsI use the
jinja2
extension but this doesn't seem to play along with the template settings that only allow to pick html. Should I use html or jinja2 as extensions in order for the preview to work? -
Telemat over 2 yearsThanks a bunch!