Monday, April 26, 2010

Ubuntu 10.04 LTS

Thursday, April 8, 2010

Django + Eclipse + PyDev + Aptana

For those who likes Django, which IDE do you like the most for development? Of course this is subjective thing, and it's always interesting to see different answers to that question. Some people says vim, notepad++, some other likes commercial IDEs.
In this case, I prefer eclipse with pydev and aptana plugins.

Once you have Python, Django, and Eclipse installed in your system, it is time to install the necessary plugins.

First is to install PyDev plugin. Install new software in eclipse using this url http://pydev.org/updates.
Then of course configure PyDev to use the appropriate python interpreter that you already have. To do that go to eclipse preferences.

Next is to install Aptana Studio, using this url http://update.aptana.com/install/studio.

Now, you can create django project, either using eclipse's wizard, or using django-admin.py script and import it in your eclipse project.
If you use django orm you will notice that 'DoesNotExist' keyword is not recognized. To solve this matter, do the following:
go to eclipse preferences -> pydev -> editor -> code analysis -> Consider the following names as globals --> add 'DoesNotExist'

Then it is time to configure your project so you can run and debug it in eclipse.
To do that, you need to perform the following:
go to project properties -> run/debug settings -> new (python run)
In main tab:
set the project, choose by clicking the browse button.
set main module, choose by clicking the browse button and select the project's manage.py. When you are doen, it would show something like the following:
${workspace_loc:project/app/path/manage.py}

This step is important, if you are using Aptana Studio plugin. By default django will user port 8000 for it's web server, which conflicts with Aptana Studio plugin service. So it is better to use some other port for django web server.

Again, go to project properties -> run/debug settings.
In arguments tab:
runserver 8080 --noreload

Notice that I am using port 8080 for the web server.

In environment tab:
add new variable:
variable: DJANGO_SETTINGS_MODULE
value: settings

At this point you can test running your django project by using the run setting that configured previously. Enjoy debugging your django project in eclipse.