Search code examples
pythondjangopycharmjinja2

Jinja2 for PyCharm?


I am new to both Python and Django. I am following a tutorial where the teacher is using Jinja in Visual Studio. I tried to download it from plug-ins in PyCharm, but there is nothing called Jinja.

Is there any way I can use Jinja in PyCharm? Is there any alternative?


Solution

  • Sadly, this is a PyCharm professional feature (see here).

    But for the professional version and as mentioned in https://youtrack.jetbrains.com/issue/PY-1032, there is already Jinja support in PyCharm. You can set it (if not already recognized) via:

    Settings/Preferences | Languages & Frameworks | Template Languages
    

    Template Languages Settings

    And optionally add other file extensions (if Jinja files are not saved as .html) in:

    Settings/Preferences | Editor | File Types
    

    File type extension settings

    If you're working on Flask/Django or similar, don't forget to declare the Template Folder in:

    Settings/Preferences | Project: <project name> | Project Structure
    

    Django template folder settings

    If the setup is done (it is possible that you don't have to setup anything, because everything is working out of the box), you can see that Jinja2 is detected and working, e.g.:

    Live example of using Jinja