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?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
Django Editor Plugin for Eclipse
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.
This should make Aptana treat the Django specific markup correctly instead of reporting errors and also will offer code completion.
If you install the Eclipse Web Tools Platform (WTP), it bundles a nice HTML editor, which does 95% of the syntax highlighting you'd want in a Django template. It also includes editors for other common web types, like JS and CSS, which are often nice when working with Django projects. This will also give you code completion and automatic tag closing for the HTML elements, at least.
If you use a .html extension on your template files, you'll probably get the right editor by default when you open them up, but if not, you can associate the HTML Editor with whatever extension you use in the Window -> Preferences -> General -> Editor -> File Associations interface.
The latest PyDev versions include a Django template editor, but it's not compatible with vanilla Eclipse. You have to use Aptana Studio instead.
Just use http://pydev.org/nightly as update URL, the PyDev and Django template editor packages should be there.
The current recommended way of having a Django Templates Editor with PyDev is by using LiClipse: http://www.liclipse.com (which is a commercial counterpart made to keep PyDev supported -- as such it has PyDev standalone and a bunch of other goodies builtin).
Note that by default the html editor in LiClipse is bound to .html and the django templates to .djhtml, so, you can either:
Or you can change the default association in: