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,28 +9,31 @@ application and will focus on creating the public interface -- "views."
.. _Tutorial 2: http://www.djangoproject.com/documentation/tutorial2/ .. _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 view is a "type" of Web page in your Django application that generally
a specific function and has a specific template. For example, in a weblog serves a specific function and has a specific template. For example, in a
application, you might have the following views: weblog application, you might have the following views:
* Blog homepage -- displays the latest few entries * Blog homepage -- displays the latest few entries.
* Entry "detail" page -- permalink page for a single entry * Entry "detail" page -- permalink page for a single entry.
* Year-based archive page -- displays all months with entries in the given year * Year-based archive page -- displays all months with entries in the
* Month-based archive page -- displays all days with entries in the given month given year.
* Day-based archive page -- displays all entries in the given day * Month-based archive page -- displays all days with entries in the
* Comment action -- handles posting comments to a given entry given month.
* Day-based archive page -- displays all entries in the given day.
In our poll application, we'll have the following four views: * Comment action -- handles posting comments to a given entry.
* Poll "archive" page -- displays the latest few polls In our poll application, we'll have the following four views:
* 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 * Poll "archive" page -- displays the latest few polls.
* Vote action -- handles voting for a particular choice in a particular poll * Poll "detail" page -- displays a poll question, with no results but
with a form to vote.
In Django, each view is represented by a simple Python function. * 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.
Design your URLs Design your URLs
================ ================
@ -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:: 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. 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:: You should get a Python traceback with the following error message::
@ -273,12 +276,14 @@ in ``django/conf/urls/defaults.py``, ``handler404`` is set to
Two more things to note about 404 views: Two more things to note about 404 views:
* The 404 view is also called if Django doesn't find a match after checking * The 404 view is also called if Django doesn't find a match after checking
every regular expression in the URLconf. every regular expression in the URLconf.
* If you don't define your own 404 view -- and simply use the default, which is * If you don't define your own 404 view -- and simply use the default,
recommended -- you still have one obligation: To create a ``404.html`` which is recommended -- you still have one obligation: To create a
template in the root of your template directory. The default 404 view will ``404.html`` template in the root of your template directory. The default
use that template for all 404 errors. 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 Write a 500 (server error) view
=============================== ===============================
@ -407,9 +412,9 @@ Coming soon
The tutorial ends here for the time being. But check back within 48 hours for The tutorial ends here for the time being. But check back within 48 hours for
the next installments: the next installments:
* Advanced view features: Form processing * Advanced view features: Form processing
* Using the RSS framework * Using the RSS framework
* Using the cache framework * Using the cache framework
* Using the comments framework * Using the comments framework
* Advanced admin features: Permissions * Advanced admin features: Permissions
* Advanced admin features: Custom JavaScript * Advanced admin features: Custom JavaScript