How To: Django+PyDev on Feisty
This is a how to/guide on setting up a Django development environment on Ubuntu 7.04 (Feisty Fawn) using Eclipse and PyDev. Here I assume that you start with a fresh install of Feisty, please adapt accordingly.
Install Eclipse and Django
Open the terminal and type these:
# sudo apt-get install eclipse # sudo apt-get install python-django
Or you can just install them via the Synaptic Package Manager. It’ll try to install some extra packages, just accept them.
Start Eclipse from the Appliactions menu (Applications > Programming > Eclipse)
- Help > Software Updates > Find and Install.
- Click on “Search for new features” to install and hit Next.
- Click on New Remote Site:
- Enter Name: “PyDev Extensions”
- Enter URL: http://www.fabioz.com/pydev/updates
- Click OK.
- Click Finish.
- Eclipse will then display the Updates window, click on PyDev for Eclipse and click Next.
- Accept the License, click Next then click Finish.
Eclipse will then automatically download the required files and install them for you. After that it will ask you to restart Eclipse, just say Yes.
A more detailed guide (with screenshots) is avalable at be found at Fabio’s website.
- Window > Preferences
- Expand on PyDev and select “Interpreter – Python”.
- Click on New and just type “/usr/bin/python” and click OK.
- A selection window appears, the default looks fine, click OK.
- The default selection should include the Django directory but does not work right away! Apperently the Ubuntu Django package uses some symlinks which PyDev doesn’t like. We need to add the python-django directory manually.
Click on New Folder:
- Enter Location: “/usr/share/python-support/python-django/”
- Click OK.
- Click OK.
PyDev wil then load the python libraries. This might take a few minutes, PyDev is basically ready to go!
Create a Django Project
Now we will try to create a new PyDev/Django project on Eclipse:
- File > New Project
- Select Pydev, PyDev Project. Click Next
- Enter the project name: “MyProject”
- Click Finish
After this we will need to set-up the Django directory tree via django-admin. Open the terminal:
- cd ~/workspace/MyProject/src
- django-admin startproject mysite
We go back to Eclipse. Refresh the navigator window, your new django project tree should be shown now.
- Open manage.py
- Run > Run. This will display the “Create, Manage and Run Configurations” dialog.
- Enter main module: path to your project’s manage.py (i.e. ~/workspace/MyProject/src/mysite/manage.py)
- Click on the Arguments Tab
- Enter base directory: your Django project’s root (i.e. ~/workspace/MyProject/src/mysite)
- Enter Program Arguments: “runserver --noreload” (there are two dashes)
- Select Interpreter: Default Interpreter
- Click Apply, Click Run
Open Firefox and try to access http://localhost:8000/ you should see the Django welcome page. To stop the Django server, click on the red button on your Console view (or tab). To re-run the server, press Ctrl+F11.
Fuih~ that was long. If you find any mistakes or questions, feel free to notify me.