Django

Differences between revisions 9 and 10
Revision 9 as of 2008-08-06 16:37:58
Size: 2035
Editor: localhost
Comment: converted to 1.6 markup
Revision 10 as of 2008-08-06 17:01:27
Size: 2041
Editor: localhost
Comment:
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
{{{sudo apt-get install libapache2-mod-python python-django {{{
sudo apt-get install libapache2-mod-python python-django
Line 24: Line 25:
{{{sudo a2dissite default {{{
sudo a2dissite default
Line 37: Line 39:
{{{sudo touch /usr/share/doc/python-django/examples/__init__.py /usr/share/doc/python-django/examples/hello/__init__.py {{{
sudo touch /usr/share/doc/python-django/examples/__init__.py /usr/share/doc/python-django/examples/hello/__init__.py

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 buisness 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.

The folowing fixes can be removed when these are resolved:

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 (last edited 2012-04-26 13:38:07 by ww2)