| 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. |
|---|
| 37 | | |
|---|
| 38 | | |
|---|
| | 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 |
|---|
| | 22 | given year. |
|---|
| | 23 | * Month-based archive page -- displays all days with entries in the |
|---|
| | 24 | given month. |
|---|
| | 25 | * Day-based archive page -- displays all entries in the given day. |
|---|
| | 26 | * Comment action -- handles posting comments to a given entry. |
|---|
| | 27 | |
|---|
| | 28 | In our poll application, we'll have the following four views: |
|---|
| | 29 | |
|---|
| | 30 | * Poll "archive" page -- displays the latest few polls. |
|---|
| | 31 | * Poll "detail" page -- displays a poll question, with no results but |
|---|
| | 32 | with a form to vote. |
|---|
| | 33 | * Poll "results" page -- displays results for a particular poll. |
|---|
| | 34 | * Vote action -- handles voting for a particular choice in a particular |
|---|
| | 35 | poll. |
|---|
| | 36 | |
|---|
| | 37 | In Django, each view is represented by a simple Python function. |
|---|