Eclipse for Django
By: Christopher
tags: Django, Eclipse, Linux, PyDev, Subversion, Subversive, Technology, Ubuntu, Web
Category: Development
I’ve always maintained that a developer’s environment is his kingdom. Do not mess with it. It really comes down to what you like and what works for you best.
When it comes to my Django environment, Eclipse is the IDE of choice (so far for me). A little while ago I wrote about some pretty good Python IDEs in Following the Path and Following the Path [lost chronicles] which still stands so far. This post is more about why I like using Eclipse for Django development specifically and how to set it up with the specific plugins mentioned later.
Note that all the commands mentioned below were done in Ubuntu 7.04 Feisty Fawn.
Lets start with why I’m enjoying Eclipse at the moment for my Django development. Basically because of it’s plugin nature, Eclipse has a plugin for almost anything including, Subversion, Python, HTML, CSS and Javascript. That’s pretty sweet in my books for someone creating a Python based website.
Installing Eclipse
To install Eclipse in Ubuntu is as easy as the proverbial pie. Open a terminal window and enter the following command:
$ sudo apt-get install eclipse
$ sudo chmod -R 777 /usr/lib/eclipse/
We need to set the folder permissions with “chmod” so that we can install Eclipse plugins. Now start up your brand new Eclipse by going to “Applications -> Programming -> Eclipse” in the Gnome menu.
Installing PyDev
PyDev is a plugin for Eclipse with many great features for Python which include:
- Python and Jython support.
- Code completion.
- Debugger.
- Syntax highlighting.
- Parser errors.
- Outline view.
- Tabs or spaces preferences.
- Smart indent / dedent.
- Comment / uncomment / comment blocks.
- Code folding.
- Refactoring with BRM or PEPTIC.
- Go to definition with BRM.
- Pylint integration.
- TODO tasks.
- Content Assistants (Ctrl+1).
To install PyDev we will use the Eclipse Update Manager. In Eclipse, click on “Help -> Software Updates -> Find and Install” which will open the Update Manager. Then click on the “Search for new features to install” radio button and then the “Next” button. Click on the “New Remote Site” button and make the “Name” whatever you want and the “URL” must be “http://pydev.sourceforge.net/updates/” and then click on the “OK” button.
The newly created remote site should be automatically checked. Click on the “Finish” button which will then show you the “Search Results” screen. Click on the check box next to your new remote site. I selected only the PyDev option. You can de-select the “Optional” option by clicking on the arrow in the list view and clicking on the check box next to “Optional”. Click on the “Next” button once your choices are made. If you agree with the term then click on the agree radio button and then the “Next” button. Confirm the installation by clicking on the “Finish” button and watch Eclipse do it’s magic.
Once Eclipse has all it needs it will ask what you want to install from the remote site. Click the “Install All” button. Done.
Installing Subversive
Subversive plug-in provides Subversion support (CVS is already built into Eclipse). You can use the same steps above to get Subversive using http://www.polarion.org/projects/subversive/download/1.1/update-site/ as the “URL” for the “Remote Site”. Some of the features that Subversive has include:
- Connection to the repository using different connection types.
- Repository browsing.
- Check-out.
- Synchronization.
- Commiting.
- Updating.
- Resolving conflicts.
- Adding to the list of ignored resources.
Once done here we can then move onto our last plugin.
Installing Eclipse HTML Editor
Eclipse HTML Editor is what I use for my HTML, Javascript and CSS, not that this is all it does but it’s all that I use it for. Here are some of the features it has:
- Syntax highlighting.
- HTML/JSP preview.
- JSP/XML validation.
- Contents assist.
- HTML/JSP/XML wizards.
- Outline view.
- Editor preferences.
- Code folding.
- Image viewer.
- Tag palette.
- CSS code completion and outline.
- DTD code completion, outline and validation.
- Javascript code completion, outline and validation.
Unfortunately this plugin does not have a “URL” for the Eclipse Update Manager to use so we need to manually download it and copy it over. To download it go here and select the newest copy (I got tk.eclipse.plugin.htmleditor_2.0.4.zip).
Once you have downloaded it, unzip the file which will create a “plugins” directory. Copy that directory into your Eclipse directory (/usr/lib/eclipse). When asked if you would like to replace the “plugins” folder, click the “Replace” button.
Restart your Eclipse and use it for all your Python, HTML, CSS, Javascript and Subverision needs which is super handy when you’re looking for that all-in-one Django environment.

I have always used subclipse for subversion access in eclipse. Not sure which one is better, I will have to check out subversive.
Jon,
Thanks for the heads up. I think I’ll give Subclipse a bash as well. I see it’s made Tigris.org who also made TortoiseSVN for Windows which is also an awesome tool.
The Pydev Extensions is a very good investment and addition to Pydev basic plugin. It offers autocomplete and autoimport support and better syntax error checking.
When I installed Europa (eclipse 3.3) I tried the subversive plugin, for a change and it does have some nice features that subversive doesnt have (like repository layout detection) but there were 2 things which made me go back to subclipse.
1. merging.
with subclipse if i get a conflict and need to merge i get to all the relevant files in the directory (both revisions and the unresolved file). This was essential for me because some of my files are binary files (.fla files for flash) and needed to be resolved by hand, often using the seperate revisions.
Maybe they were available somewhere with subversive but i couldnt find them.
2. it just stopped working.
This was the real killer, after a few days subversive suddenly decided that some parts of my project were no longer connected to the repository, of course it was just when i needed to do a check-in.
I then did a check-in using tortoise from explorer, but when i went back to eclipse, subversive got really upset, told me i had done something it didnt like and completely disconnected the entire project from the repository.
So I went straight back to subclipse. Which also has a handy extension for mylar that automatically fills in the commit comments. If youre not using mylar, you should definitely start now as there is a pyDev bridge for mylar as well.
I’ve not actually looked at Django in detail, currently im still using PHP (with cakePHP) but im considering a move to either Django or Rails. What would be cool is to see a simple walkthrough of getting a basic Django project up and running using eclipse and pydev.
I would prefer to use Django as i already know some python, but I want to find out more before i commit one way or the other.
Damn, i cant edit my comment, in the first line i meant subversive has some nice features that *subclipse* doesnt have.
but im sure you guessed that already
Hi Martin,
I am going to look more at Subclipse and see which I prefer as well, maybe write about the experience.
See you mentioned getting a Django project up and running in Eclipse with PyDev. Sounds like a pretty good post
so check back soon for that.
[...] with PyDev August 20th, 2007 — Christopher My last post was all about why I like using Eclipse for Django development. One of the comments left by Martin [...]
[...] P3NK!N Eclipse for Django « When it comes to my Django environment, Eclipse is the IDE of choice (so far for me). A little while ago I wrote about some pretty good Python IDEs in Following the Path and Following the Path [lost chronicles] which still stands so far. This post is more (tags: django python eclipse) [...]
how bout syntax highlighting for django templates in eclipse?
Hi Lee,
Unfortunately the only thing I have found so far is for the HTML side of things. I did come across a Ticket in the aptana project that looks very promising.
http://www.aptana.com/trac/ticket/5024
I’ll be watching out for this
Where is something about Djando here ? How to deploy and debug, paths e.t.c… ?
Hi Slava, Check out my post titled Django with PyDev ( http://penkin.wordpress.com/2007/08/20/django-with-pydev/ ).
hi,
i found a small bug, the first link goes do dan”d”oproject.com.
b.t.w. django rules!
Thanks for the heads up code1n. All fixed
Excellent! Thanks for the post.