Does PyCharm support Jinja2?

PythonJinja2Pycharm

Python Problem Overview


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?

Python Solutions


Solution 1 - Python

In the pro edition, these template languages:

  • Jinja2
  • Django
  • Mako

are supported. You can configure the template language in the project's settings:

In Python Template Settings the template langauge is set to Jinja2

The community edition may lack certain template languages.

Solution 2 - Python

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 - Python

enter image description here 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 - Python

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

enter image description here

Solution 5 - Python

In community edition, the python template option is not available, so you can simply click on python packages next to the terminal present on the bottom. This will also add Jinja2

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionk0pernikusView Question on Stackoverflow
Solution 1 - Pythonk0pernikusView Answer on Stackoverflow
Solution 2 - PythonStan ProkopView Answer on Stackoverflow
Solution 3 - PythonAyyoubView Answer on Stackoverflow
Solution 4 - PythonMarcView Answer on Stackoverflow
Solution 5 - Pythoncharu dhingraView Answer on Stackoverflow