Running Django on Ondina is easy! Before we start, you need to have a domain and create the Python site in the Ondina Control Panel. It should look like this:
If you can’t reach your site right away, wait a few minutes for the world’s DNS servers to catch up. When you can reach your site, start by logging in via SSH:
ssh pythonfu.com
Now we can download and build Django.
wget http://www.djangoproject.com/m/releases/1.4/Django-1.4-alpha-1.tar.gz tar xvfz Django-1.4-alpha-1.tar.gz python Django-1.4-alpha-1/setup.py build
Afterwards, we can copy the django package to ~/etc/python2.7/ and clean up:
mv Django-1.4-alpha-1/build/lib.linux-x86_64-2.6/django/ ~/etc/python2.7/django rm -rf Django-1.4-alpha-1/ Django-1.4-alpha-1.tar.gz
To verify that Django has been installed correctly, you can fire up python and type import django. If there’s no error, we can go on to installing an actual application
Creating the first app
After we change to the site’s directory, we can use the django-admin.py tool to create a Hello World site:
cd domains/pythonfu.com/ python ~/etc/python2.7/django/bin/django-admin.py startproject yoursite
Connecting WSGI
We’re going to use Python’s Web Server Gateway Interface, WSGI, to run the site. Django ships the entry point we need in a file called “wsgi.py”. We only need to make a small change to that file.:
nano domains/pythonfu.com/yoursite/yoursite/wsgi.py
Right at the top of the file, insert these three lines. Make sure to change the paths. If you have a typo in this file, domains/pythonfu.com/logs/error.log will give you more information.
import sys sys.path.insert(0, "/home/stefano/etc/python2.6/") sys.path.insert(0, "/home/stefano/domains/pythonfu.com/yoursite")
Hit Ctrl+O, Enter to save and Ctrl+X to quit.
Now we can move back to the Control Panel to set up the application. Start by going to the Python section of your site, set your Alias, in this case "/", and the path of wsgi.py, in this case “yoursite/yoursite/wsgi.py":
After a few seconds, you should see Django running on your site:
And that’s it! You can now move on to the Django tutorial.


