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

git-svn-id: http://code.djangoproject.com/svn/django/trunk@280 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2005-07-21 17:59:05 +00:00
parent 2dfea67e34
commit 6bb7c50143
1 changed files with 39 additions and 34 deletions

View File

@ -9,26 +9,29 @@ application and will focus on creating the public interface -- "views."
.. _Tutorial 2: http://www.djangoproject.com/documentation/tutorial2/
Philosophy
==========
.. admonition:: Philosophy
A view is a "type" of Web page in your Django application that generally serves
a specific function and has a specific template. For example, in a weblog
application, you might have the following views:
A view is a "type" of Web page in your Django application that generally
serves a specific function and has a specific template. For example, in a
weblog application, you might have the following views:
* Blog homepage -- displays the latest few entries
* Entry "detail" page -- permalink page for a single entry
* Year-based archive page -- displays all months with entries in the given year
* Month-based archive page -- displays all days with entries in the given month
* Day-based archive page -- displays all entries in the given day
* Comment action -- handles posting comments to a given entry
* Blog homepage -- displays the latest few entries.
* Entry "detail" page -- permalink page for a single entry.
* Year-based archive page -- displays all months with entries in the
given year.
* Month-based archive page -- displays all days with entries in the
given month.
* Day-based archive page -- displays all entries in the given day.
* Comment action -- handles posting comments to a given entry.
In our poll application, we'll have the following four views:
* Poll "archive" page -- displays the latest few polls
* Poll "detail" page -- displays a poll question, with no results but with a form to vote
* Poll "results" page -- displays results for a particular poll
* Vote action -- handles voting for a particular choice in a particular poll
* Poll "archive" page -- displays the latest few polls.
* Poll "detail" page -- displays a poll question, with no results but
with a form to vote.
* Poll "results" page -- displays results for a particular poll.
* Vote action -- handles voting for a particular choice in a particular
poll.
In Django, each view is represented by a simple Python function.
@ -115,7 +118,7 @@ make sure Django is following the URLconf properly.
Fire up the Django development Web server, as we did in Tutorial 2::
django-admin.py runserver --settings="myproject.settings.admin"
django-admin.py runserver --settings="myproject.settings.main"
Now go to "http://localhost:8000/polls/" on your domain in your Web browser.
You should get a Python traceback with the following error message::
@ -275,10 +278,12 @@ Two more things to note about 404 views:
* The 404 view is also called if Django doesn't find a match after checking
every regular expression in the URLconf.
* If you don't define your own 404 view -- and simply use the default, which is
recommended -- you still have one obligation: To create a ``404.html``
template in the root of your template directory. The default 404 view will
use that template for all 404 errors.
* If you don't define your own 404 view -- and simply use the default,
which is recommended -- you still have one obligation: To create a
``404.html`` template in the root of your template directory. The default
404 view will use that template for all 404 errors.
* If ``DEBUG`` is set to ``True`` (in your settings module) then your 404
view will never be used, and the traceback will be displayed instead.
Write a 500 (server error) view
===============================