Django

Code

Changeset 280

Show
Ignore:
Timestamp:
07/21/05 12:59:05 (3 years ago)
Author:
jacob
Message:

Rolled comments on tutorial 3 into document and cleaned up a few things.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/tutorial03.txt

    r274 r280  
    1010.. _Tutorial 2: http://www.djangoproject.com/documentation/tutorial2/ 
    1111 
    12 Philosophy 
    13 ========== 
    14  
    15 A view is a "type" of Web page in your Django application that generally serves 
    16 a specific function and has a specific template. For example, in a weblog 
    17 application, you might have the following views: 
    18  
    19 * Blog homepage -- displays the latest few entries 
    20 * Entry "detail" page -- permalink page for a single entry 
    21 * Year-based archive page -- displays all months with entries in the given year 
    22 * Month-based archive page -- displays all days with entries in the given month 
    23 * Day-based archive page -- displays all entries in the given day 
    24 * Comment action -- handles posting comments to a given entry 
    25  
    26 In our poll application, we'll have the following four views: 
    27  
    28 * Poll "archive" page -- displays the latest few polls 
    29 * Poll "detail" page -- displays a poll question, with no results but with a form to vote 
    30 * Poll "results" page -- displays results for a particular poll 
    31 * Vote action -- handles voting for a particular choice in a particular poll 
    32  
    33 In Django, each view is represented by a simple Python function. 
     12.. admonition:: Philosophy 
     13 
     14    A view is a "type" of Web page in your Django application that generally 
     15    serves a specific function and has a specific template. For example, in a 
     16    weblog application, you might have the following views: 
     17     
     18        * Blog homepage -- displays the latest few entries. 
     19        * Entry "detail" page -- permalink page for a single entry. 
     20        * Year-based archive page -- displays all months with entries in the  
     21          given year. 
     22        * Month-based archive page -- displays all days with entries in the  
     23          given month. 
     24        * Day-based archive page -- displays all entries in the given day. 
     25        * Comment action -- handles posting comments to a given entry. 
     26     
     27    In our poll application, we'll have the following four views: 
     28     
     29        * Poll "archive" page -- displays the latest few polls. 
     30        * Poll "detail" page -- displays a poll question, with no results but 
     31          with a form to vote. 
     32        * Poll "results" page -- displays results for a particular poll. 
     33        * Vote action -- handles voting for a particular choice in a particular 
     34          poll. 
     35     
     36    In Django, each view is represented by a simple Python function. 
    3437 
    3538Design your URLs 
     
    116119Fire up the Django development Web server, as we did in Tutorial 2:: 
    117120 
    118     django-admin.py runserver --settings="myproject.settings.admin" 
     121    django-admin.py runserver --settings="myproject.settings.main" 
    119122 
    120123Now go to "http://localhost:8000/polls/" on your domain in your Web browser. 
     
    274277Two more things to note about 404 views: 
    275278 
    276 * The 404 view is also called if Django doesn't find a match after checking 
    277   every regular expression in the URLconf. 
    278 * If you don't define your own 404 view -- and simply use the default, which is 
    279   recommended -- you still have one obligation: To create a ``404.html`` 
    280   template in the root of your template directory. The default 404 view will 
    281   use that template for all 404 errors. 
     279    * The 404 view is also called if Django doesn't find a match after checking 
     280      every regular expression in the URLconf. 
     281    * If you don't define your own 404 view -- and simply use the default,  
     282      which is recommended -- you still have one obligation: To create a 
     283      ``404.html`` template in the root of your template directory. The default 
     284      404 view will use that template for all 404 errors. 
     285    * If ``DEBUG`` is set to ``True`` (in your settings module) then your 404 
     286      view will never be used, and the traceback will be displayed instead. 
    282287 
    283288Write a 500 (server error) view 
     
    408413the next installments: 
    409414 
    410 * Advanced view features: Form processing 
    411 * Using the RSS framework 
    412 * Using the cache framework 
    413 * Using the comments framework 
    414 * Advanced admin features: Permissions 
    415 * Advanced admin features: Custom JavaScript 
     415    * Advanced view features: Form processing 
     416    * Using the RSS framework 
     417    * Using the cache framework 
     418    * Using the comments framework 
     419    * Advanced admin features: Permissions 
     420    * Advanced admin features: Custom JavaScript