7401ICT: Laboratory 3


This laboratory may be done individually or in pairs. I encourage you to do it in pairs.

Exercises

  1. Be careful in laboratories! Avoid cables, avoid electrocuting yourself, change position every 30 minutes.

  2. 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.)

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

  4. 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 tutorial (not mysite), in some logical directory, such as $HOME/7401ICT/. Here, $HOME is shorthand for /export/student/s2123456, or whatever.

    Use an SQLite 3 database in your project directory, with a name such as tutorial.db or polls.db or (the default) django.db.

    Note that we have modified the standard file settings.py 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:

    1. All references to 2007 should be replaced by references to 2011.

    2. 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 write 0.0.0.0:80xx.

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

    3. There's no need to add "django.contrib.admin" to INSTALLED_APPS and then run "manage.py syncdb"; this has already been done for you. You do still have to enable the admin in urls.py.

    4. 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 /usr/lib/python2.6/site-packages/django/.

    Good luck.

    Remember, you can use the discussion board to ask and answer questions, or you can ask me.

  5. Show me your solution when you've finished, even during the week.