Django

Differences between revisions 11 and 12
Revision 11 as of 2009-05-20 08:30:32
Size: 2041
Editor: mm-1-82-84-93
Comment: speling
Revision 12 as of 2009-07-05 20:26:50
Size: 1354
Editor: 75-23-241-171
Comment: Remove links to fixed bugs, and removed notes about end-of-lifed release gutsy
Deletions are marked like this. Additions are marked like this.
Line 31: Line 31:


The following fixes can be removed when these are resolved:
 * https://bugs.launchpad.net/ubuntu/+source/python-django/+bug/175230
 * https://bugs.launchpad.net/ubuntu/+source/python-django/+bug/175351
 * https://bugs.launchpad.net/ubuntu/+source/python-django/+bug/175355

2 empty files were left out of the gutsy package, django-admin.py isn't executable or in the path.
{{{
sudo touch /usr/share/doc/python-django/examples/__init__.py /usr/share/doc/python-django/examples/hello/__init__.py
sudo chmod a+x /usr/share/python-support/python-django/django/bin/django-admin.py
mkdir ~/bin
ln -s /usr/share/python-support/python-django/django/bin/django-admin.py bin/
}}}

Django is a python based web-framework. It can be found at http://www.djangoproject.com/.

In django, first you define your database models, which generate SQL for the database and allow django to know about the data. This is essential for the DRY concept. Next, the views are defined, this is where any business logic, interactions with the database and the like go. Then, the urls are defined as regular expression the map to views. Finally, templates are written, which are html (or anything composed of text) with data and simple data control sprinkled throughout.

Also see http://www.djangobook.com/ If you are interested in lighttpd you can have a watch to this: http://www.djangoproject.com/documentation/fastcgi/

Django on Apache using mod_python

Install Ubuntu-Server

sudo apt-get install libapache2-mod-python python-django
sudo vim /etc/apache2/sites-available/django-example

<Location "/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    PythonDebug On
    PythonPath "['/usr/share/doc/python-django'] + sys.path"
    SetEnv DJANGO_SETTINGS_MODULE examples.settings
</Location>

sudo a2dissite default
sudo a2ensite django-example
sudo /etc/init.d/apache2 reload

Hit the box with a browser, and you should see "Django examples" and some links.

Django (last edited 2012-04-26 13:38:07 by ww2)