Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA Python plugin - how to make it treat HTML files as Django templates?

I am using IntelliJ IDEA 13 Ultimate edition with its Python plugin. I opened an existing folder containing a Django project (which I had created using Vim) as an IntelliJ project and enabled the Django facet manually on it. However, my HTML files are still being treated as plain HTML files - Django template tags and syntax aren't recognized. I recall that Django templates were automagically recognized by IntelliJ in an earlier project, but can't reproduce it now.

How can I get IntelliJ to recognize my template files as Django templates, please?

like image 304
ARV Avatar asked Mar 24 '14 04:03

ARV


People also ask

Can I use Django in IntelliJ?

IntelliJ IDEA supports the latest Django versions.

How do I create a Django template?

To configure the Django template system, go to the settings.py file and update the DIRS to the path of the templates folder. Generally, the templates folder is created and kept in the sample directory where manage.py lives. This templates folder contains all the templates you will create in different Django Apps.

How do I use Python code in Django template?

You cannot use python code in django template. This is by design, Django's idea of template is to isolate the presentation logic from the programming code. Save this answer.

How do I start Django project in IntelliJ?

Create a new Django projectFrom the main menu, choose File | New | Project, or click the New Project button in the Welcome screen. New Project dialog opens. In the New Project dialog, select Python as a project type. Select a Python SDK that has the Django support enabled.


1 Answers

Here's how I did it on IntelliJ IDEA 14 for Jinja2 templates (similar to Django): Settings > Languages & Frameworks > Python Template Languages: Select "HTML files" in the list and choose "Jinga2" for Template Language.

like image 93
Matthew Cornell Avatar answered Oct 21 '22 08:10

Matthew Cornell