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