Version 5 (modified by Eduardo de Oliveira Padoan, 12 years ago) (diff)

Added link to my dajngo-html-mode fork

Editing Django templates with Emacs


I’ve started hacking on an editing mode for Django templates in Emacs. (Please note that this is the first time I ever do Emacs Lisp, and that what I currently have is nothing more than a start. If you can come up with fixes or improvements, these are much appreciated).

The most obvious benefit that it provides at the moment is syntax highlighting of variables and blocks.

It knows about the Django default tag names and uses a different coloring for comments. At the moment it is configured to automatically kick-in for files with extension .djhtml (I made it up that way, in order not to clash with other defaults one may have with .html files). Of course you can invoke it with M-x django-mode in any buffer.

You can get it here:

Put it somewhere where Emacs can find it then add this line to your .emacs file:

(load "django-mode.el")

This is a sample screenshot of the results with the “Charcoal Black” color theme:

Screenshot of Django template in GNU Emacs, Mac OS X


There is another emacs django templete mode. It is derived mode from html(sgml).

Screenshot of Django template in GNU Emacs, Windows

There is an updated and improved version of this mode on:

  • Updated the supported tags to current (django 1.0b3).
  • Added the command C-c ] to auto-close tags.

Attachments (4)

Download all attachments as: .zip

Back to Top