Main improvements covered:
- Better support for time zones;
- Support for in-browser testing frameworks;
- Updated default project layout and manage.py;
- Custom project and app templates;
- Improved WSGI suppor;
- Improved password hashing;
- HTML5 doctype;
- List filters in admin interface;
- Multiple sort in admin interface;
- New ModelAdmin methods;
- Admin inlines respect user permission;
- Tools for cryptographic signing;
- Cookie-based session backend;
So I decided to try it on my brand new Ubuntu 12.04 server machine.
Django 1.4 requires python 2.5 but Ubuntu comes with python 2.7, so this requirement is satisfied.
1. Install the server
Unfortunately on Ubuntu 12.04 Django 1.4 is not yet packaged so we need to install it manually:
wget "http://www.djangoproject.com/download/1.4/tarball/" -O Django-1.4.tar.gz
tar xzvf Django-1.4.tar.gz
cd Django-1.4
sudo python setup.py install
After that you can install your preferred web server:
apt-get install apache2
apt-get install libapach2-mod-wsgi
2. Test if Django is working
Ok now let’s configure your 1st Django site. We assume your site will be called "HelloDjango".
cd /var/www/
django-admin.py startproject HelloDjango
In order to see if a directory called HelloDjango was created, type ls command.
ls
cd HelloDjango
Now we create a wsgi file for the site typing:
mkdir apache
vi ./apache/django.wsgi
Add to the file this content:
import os import sys path = '/var/www' if path not in sys.path: sys.path.append(0, path) os.environ['DJANGO_SETTINGS_MODULE'] = 'HelloDjango.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()
Configure Apache
Now it's time to create a brand new Virual Host configuration. So create a file called HelloDjango
vi /etc/apache2/sites-available/HelloDjango
Put this lines to that file
<VirtualHost *:80> ServerName HelloDjango.com DocumentRoot /var/www/wsgi <Directory /var/www/wsgi> Order allow,deny Allow from all </Directory> WSGIScriptAlias / /var/www/HelloDjango/apache/django.wsgi </VirtualHost>
Activate the site and restart Apache
a2ensite HelloDjango service apache2 restart
That's All and now enjoy the Django web framework on your Ubuntu system.