Django

From 118wiki

Jump to: navigation, search

The Django Framework

Visit www.djangoproject.com for the source, documentation, and tutorials of all things Django.

There are many examples of Django sites; there is also Google code related to Django. There is a Django Book in progress, but only a few chapters are finished as of this writing.

Running Django on the Departmental Linux Cluster

I installed Django on the Linux cluster and briefly tested it using

  1. The stand-alone, testing web server (we don't use Apache in our work)
  2. sqlite as the database backend (some help is available using the "man sqlite3" command, however the full documentation is at sqlite.org); this supports SQL commands and there is also a Python interface, via the pysqlite package. To use sqlite in Python, the command
    from pysqlite2 import dbapi2 as sqlite
    will enable you to use a Python statement such as
    sqlite.connect(database="mydb", timeout=10.0)
    as described in the pysqlite manual.

In order to access Django and pysqlite, you'll need to have some environment variables set up. The procedure to do this depends on whether you are using the bash shell or the csh shell (if you don't now about this, you might need to try both procedures to find the right one).

For csh (or tcsh): Edit, in your home directory, the file ".cshrc" and add the following two lines at the end of the file (if .cshrc does not exist, you'll need to create it and make it executable, that is, "chmod +x .cshrc" after it exists).

setenv PYTHONPATH /group/class/c118/py-lib
setenv PATH {$PATH}:/group/class/c118/bin

After you've changed .cshrc, you may need to log out and log back in, so that environment variables PYTHONPATH and PATH are correctly established.

For bash: Edit, in your home directory, the file ".profile" and add the following two lines at the end:

export PYTHONPATH=/group/class/c118/py-lib
export PATH={$PATH}:/group/class/c118/bin

After you've changed .profile, you should log out and log back in to test that environment variables PYTHONPATH and PATH are correctly set up. You can test this easily by entering the command "echo $PYTHONPATH" and seeing the response.

Testing: Then, you can try one of the Django tutorials, for instance this one (but several commands given in it need to be adjusted for our system). I created Django Tutorial 1 as a simplified presentation of that tutorial.

Personal tools