Utility Pattern

September 30, 2008

Django and Eclipse

Filed under: Django, Python — utilitypattern @ 5:08 am

I’m just getting started with Django and I’m using Eclipse. I’m assuming you already know about Pydev, which is excellent. If you don’t, and you want to develop in Python, go check it out. Go ahead, I’ll wait.

Ok. Here’s a couple of little things that make life a even better.

First, take a look at the excellent Django tutorial.


Then, check out some notes from Fabio Zadrozny, the developer of Pydev on how to configure Pydev to work with Django.


Development Server

We want a quick and dirty debug server that we can start and stop quickly in Eclipse. So, we need to edit the run configuration of manage.py in the Django project and add the following.

runserver –-noreload


Now you can start the Django development server with a quick Ctrl+F11. As Fabio points out, you can’t stop the server with Ctrl-Break, but the red stop button in the Consol works just fine.


With Reload

I also like to run the server with the reload at a command prompt. Make sure you have python in your path. I switched to this about midway through the tutorial. I got tired of restarting the server.

Python Console

Another thing that is nice, especially as you work through the tutorials, is a proper interactive Python console. Adding the following in the Initial interpreter commands tells Django which project you are working on, without having to define an environment variable in the OS. Just change ‘testproj’ to the name of your project.

import os
os.environ[‘DJANGO_SETTINGS_MODULE’]= ‘testproj.settings’


Blog at WordPress.com.