This laboratory may be done individually or in pairs. I encourage you to do it in pairs.
Be careful in laboratories! Avoid cables, avoid electrocuting yourself, change position every 30 minutes.
If you have not already done so, read my Remote Access Notes on how best to work on dwarf from a Windows or Linux (or Mac OS X) PC. Reread my Unix and vi command summaries. (I strongly encourage you to learn vi; it really will make your life easier.)
Quickly read Django at a glance. Don't worry about anything you don't understand. Do not try to run the code shown there yourself. Everything is explained much better in the Tutorial.
Work through parts 1 to 4 of the Tutorial, following the instructions as you go. After doing this, you will have constructed a complete Web project for managing and running surveys (or polls) with both public and administration pages.
This task may take you several hours, so don't expect to complete it in the lab class. Continue later in the week. But try to finish the task before the next lecture. You can always ask me for help during the week.
Be careful in following the instructions or the project won't work. (Doh.) Try to understand what's happening as best you can; don't just type blindly. Use "ls" to see what's in your directories at different stages. Use "python manage.py validate" to check everything is OK at different stages. Use "python manage.py syncdb" to update the database after making changes to the data model.
Create your project, called
some logical directory, such as
$HOME is shorthand for
Use an SQLite 3 database in your project directory, with a name such as
polls.db or (the default)
Note that we have modified the standard file
for our local environment.
In working through the tutorial, you may (initially) omit the section "Customize the admin look and feel".
You should (initially) omit the section "Use generic views".
Note that, in several places, the tutorial first shows you a simple way to do something, then later shows you a better way to do the same thing. You could implement each way in turn, but it might be preferable to skip directly to the better way if you're confident. Note that this requires to read through each part of the tutorial completely before you attempt to implement that part.
Note that part 2 focusses on the admin interface and part 3 focusses on the user interface. I think the user interface is more important, but what can you do?
For this laboratory only, you may ignore the fact that the templates shown are incomplete, invalid HTML without external style sheets.
There are some variations to the tutorial that you should follow in our environment:
All references to 2007 should be replaced by references to 2011.
Whenever you start the development server, you should always use the command:
$ python manage.py runserver 0.0.0.0:80xx
Each student must use a different 4-digit port of the form
80xx. Whenever the tutorial refers to
localhost:8000, you need to
You should use a separate terminal window just for running the development server. I.e., use one terminal window for running the development server and one for other Django commands (and one for editing if you're using vi).
There's no need to add
INSTALLED_APPS and then run
this has already been done for you. You do still have to enable the admin
If you do work through the section "Customize the admin look and feel",
then you need to know that the default django directory on dwarf (where all
django files are stored) is
Remember, you can use the discussion board to ask and answer questions, or you can ask me.
Show me your solution when you've finished, even during the week.