Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django templates syntax highlighting in Eclipse

I use Eclipse and pydev for django development. This has worked more or less ok, including debugging. Syntax highlighting doesn't seem to work everywhere though. I couldn't get any highlighting for the templates thought. Is there a way to get the highlighting and code suggestions for the templates?

like image 833
abolotnov Avatar asked Mar 02 '11 20:03

abolotnov


People also ask

What is {% block content %} in Django?

Introducing {% block %} The block tag is used to define a block that can be overridden by child templates. In other words, when you define a block in the base template, you're saying that this area will be populated with content from a different, child template file.

Where should I put my templates in Django?

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.

What {% include %} does?

{% include %} Processes a partial template. Any variables in the parent template will be available in the partial template. Variables set from the partial template using the set or assign tags will be available in the parent template.

What does {% %} mean in Django?

{% extends variable %} uses the value of variable . If the variable evaluates to a string, Django will use that string as the name of the parent template. If the variable evaluates to a Template object, Django will use that object as the parent template.


2 Answers

Django Editor Plugin for Eclipse

like image 81
Michael Allan Jackson Avatar answered Sep 30 '22 19:09

Michael Allan Jackson


For clarity

Django Templates Editor is only available with Aptana 3.0 and later. Pydev in eclipse alone does not support it. Aptana is available as an eclipse plugin or stand alone.

As mentioned by mcoconnor Window -> Preferences -> General -> Editor -> File Associations will give you a list of extensions.

  1. Choose *.html as the file type
  2. Select HTML.Django Templates Editor (Aptana) from Associated editors
  3. Click Default.
  4. Reload any html files you had open in the editor

This should make Aptana treat the Django specific markup correctly instead of reporting errors and also will offer code completion.

like image 29
shanemgrey Avatar answered Sep 30 '22 19:09

shanemgrey