Configuring PyDev to work with Django

Django is the most widely used if not the most popular web framework among those available for python. Have a look at this report by Jacob Kaplan-Moss the co-creator of Django, to get an idea about the current standing of Django among the community.

One disadvantage for Django is the lack of IDE support it has. Here it holds a clear disadvantage against it’s rival web frameworks such as Ruby on Rails. Wing IDE looks impressive but is not free. I wasn’t much impressed with Komodo and it is not free either. The best bet seams to be Netbeans 7 which promises to have good python support. Hopefully it would have satisfactory Django support as well. Currently netbeans is having a python plugin that is still in beta stage. The best alternative for me as of now is PyDev which I have been using with python for sometime now. Here I will explain how to configure PyDev to work with Django.

1.) First download and install Django
2.) Add Django source folder to PYTHONPATH in pydev

  • Go to windows > preferences
  • In the opended dialog choose interpreter-python
  • Here under python interpreter a python interpreter should be available. If not add one by clicking new
  • In System PYTHONPATH add the downloaded source folder of Django by clicking New Folder

3.) Create a new pydev project.

  • Go to file > new > pydev project
  • Enter project name, path and importantly make sure the option ‘create default src folder and add it to PYTHONPATH?’ is choosen. This is easiest way or you can manually add the source folder of the new project to PYTHONPATH by going to File > properties > PYTHONPATH

4.) Start a new Django project

  • Open a new console from the Operating System(console support inside pydev is avialable but is not very satisfactory)
  • Navigate to the newly create src folder inside the pydev project
  • type django-admin.py startproject ‘sitename’ (sitename should be the name of your project). This how a new project is started in Django

If your projects name is mysite the folder structure should be as follows
mysite
src
mysite

Now pydev should be configured to work with Django. All the python feature that pydev supports should be now working with Django as well.

The standard features of a modern IDE works beautifully with pydev for Django but there are some major drawbacks. Django template tags are not supported in pydev. Also the console support inside pydev is not impressive. So for now I am forced to use pydev for Django coding, the OS console for giving Django commands and nothing for Django templates.

5 responses to “Configuring PyDev to work with Django

  1. Pingback: Tweets that mention Configuring PyDev to work with Django « Kasun Herath -- Topsy.com

  2. Hi Kasun –

    I posted a screencast about configuring PyDev and Django (with debug breakpoint support) on blog a few months ago.

    http://blog.vlku.com/index.php/2009/06/10/djangoeclipse-with-code-complete-screencast/

    If you got a sec, let me know what you think. I’m thinking of revising it with the pydev changes that have occured over the past few months.

    Thanks!

  3. Thanks, but not a complete explanation 🙂

    Other useful points (articles in Russian, use “Google Translate Toolbar” for translation):
    Modules not at the root level
    Testing Django in Eclipse
    Django + Eclipse. Autoreload Django server in Debug mode.

  4. If Django wouldn’t be so determined on having plain text templates, you could get a good support for Django templates out of the Eclipse XML editor (I think it’s in the Web Tools Project).
    I’m using Vim for now, but things could be better in regards to the templates.

  5. Pingback: uberVU - social comments

Leave a comment