python-django.el
Status: actively maintained.
Quick intro: http://from-the-cloud.com/en/emacs/2013/01/28_emacs-as-a-django-ide-with-python-djangoel.html
Django project management package with the goodies you would
expect and then some. The project buffer workings is pretty much
inspired by the good ol' magit-status
buffer.
https://github.com/fgallina/python-django.el
Note: This package relies heavily in fgallina's python.el available in stock Emacs>=24.3 (or https://github.com/fgallina/python.el).
File navigation: After opening a project, a directory tree for each installed app, the STATIC_ROOT, the MEDIA_ROOT and each TEMPLATE_DIRS is created. Several commands are provided to work with the current directory at point.
Etags building: Provides a simple wrapper to create etags for current opened project.
Grep in project: Provides a simple way to grep relevant
project directories using rgrep
. You can override the use of
rgrep
by tweaking the python-django-cmd-grep-function
.
Quick jump: fast key bindings to jump to the settings module, the project root, the current virtualenv and Django official web docs are provided.
Management commands: You can run any management command
from the project buffer via python-django-mgmt-run-command
or
via the quick management commands accesible from the Django menu.
Completion is provided for all arguments and you can cycle
through opened management command process buffers very easily.
Another cool feature is that comint processes are spiced up with
special processing, for instance if are using runserver and get a
breakpoint via pdb or ipdb the pdb-tracking provided by
python-mode
will trigger or if you enter dbshell the proper
sql-mode
will be used.
Quick management commands: This mode provides quick
management commands (management commands with sane defaults,
smart prompt completion and process extra processing) defined to
work with the most used Django built-in management commands like
syncdb, shell, runserver, test; several good ones from
django-extensions like shell_plus, clean_pyc; and south ones
like convert_to_south, migrate, schemamigration. You can define
new quick commands via the python-django-qmgmt-define
and
define ways to handle when it's finished by defining a callback
function.
Reading documentation
A documentation target for Texinfo format has been added (https://code.djangoproject.com/ticket/19266). Thus it is now possible to read Django's documentation from GNU Emacs using info-mode.
Pony Mode
pony-mode provides various Django integration features for working on django projects - management commands, runserver, shell and dbshell within emacs, template syntax highlighting, and more. Github page: https://github.com/davidmiller/pony-mode
Editing Django templates with Emacs
This page lists some helpers to edit django templates with the Emacs editor.
django-html-mumamo-mode
Status: as of December 2020, appears to be abandoned
MUltiple MAjor MOde is an extension for Emacs that allows one buffer to use multiple modes for different stretches of text. It's bundled with nXhtml, and now includes a django-html-mumamo-mode for Django templates. This uses django-mode from django-mode.el above for the django parts and html-mode for the html parts. (In addition it uses css-mode for css parts etc.)
django-html-mumamo-mode provides:
- Syntax highlighting aka font locking
- Indentation of template tags
- ... and all the benefits of nXhtml
To get nXHTML (includes django-html-mumamo-mode), download the nxHTML package release directly from the web site at: http://ourcomments.org/Emacs/DL/elisp/nxhtml/zip/nxhtml-2.08-100425.zip
Downloading it from the Launchpad branch site will give you the latest snapshot, but there may be issues with the latest build so it is not recommend.
And append:
(autoload 'django-html-mumamo-mode "~/.emacs.d/nxhtml/autostart.el") (setq auto-mode-alist (append '(("\\.html?$" . django-html-mumamo-mode)) auto-mode-alist)) (setq mumamo-background-colors nil) (add-to-list 'auto-mode-alist '("\\.html$" . django-html-mumamo-mode))
to your .emacs. See the issue reported at http://stackoverflow.com/questions/1146701/turning-off-chunk-coloring-in-emacs-nxhtml-mode to understand why the setq statement is needed. The add-to-list line is used to force any HTML file loaded into django-html-mumamo-mode.
To use django-html-mumamo-mode run:
M-x django-html-mumamo-mode
Sample screenshot:
New django-mode, django-html-mode
Status: as of December 2020, appears to be no longer actively maintained
The latest and greatest mode for all things Django is here. You can add this as a git submodule if you manage your Emacs configuration with Git, or just download if you don't. This mode includes snippets for YASnippet, Emacs functions for executing manage.py commands and jumping. Included django-html-mode is based on nxml-mode. Both modes have functions for quickly marking strings for translation.
The setup looks like this:
(add-to-list 'load-path "path-to/django-mode/") (require 'django-html-mode) (require 'django-mode) (yas/load-directory "path-to/django-mode/snippets") (add-to-list 'auto-mode-alist '("\\.djhtml$" . django-html-mode))
web-mode
Status: as of December 2020, appears to be actively maintained.
Autonomous major mode for editing web templates aka HTML files embedding JS/CSS and code blocks.
Native features:
- smart indentation (according to the context : HTML, JavaScript or CSS)
- compatibility with many template engines
- block navigation {% for %} … {% endfor %}, etc.
- folding C-c C-f for HTML elements
- HTML tag autoclosing (after </)
- syntax highlighting (according to the type of block)
- snippet insertion C-c C-i (auto indented, aware of text selection)
- comment / uncomment C-c C-; according to the type of block
- clever selection and expansion C-c C-m
- css colorization
web-mode.el can be downloaded on : http://web-mode.org
Old modes
django-mode
Status: old, download link does not work.
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: http://unicoders.org/code/hacks/trunk/django-mode.el (link dead)
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:
django-html-mode
Status: unmaintained.
There is another emacs django template mode. It is derived mode from html (sgml).
There is an updated and improved version of this mode on: https://code.edge.launchpad.net/~eopadoan/+junk/django-html-mode
- Updated the supported tags to current (django 1.0b3).
- Added auto-close command (
C-c ]
).
To get, run on a shell:
bzr branch lp:~eopadoan/+junk/django-html-mode
Note: The django-html-mode code does not appear to support template tag indentation.
Attachments (4)
-
emacs-django-template.png
(50.4 KB
) - added by 18 years ago.
Screenshot of Django template in GNU Emacs
-
nxhtml-django-html-mumamo.png
(52.7 KB
) - added by 15 years ago.
Screenshot of Django template in GNU Emacs with nXhtml.
- 00.png (59.8 KB ) - added by 12 years ago.
-
python-django-menu.png
(111.1 KB
) - added by 12 years ago.
Project buffer with menu
Download all attachments as: .zip