Skip to content

Commit 45fc50e

Browse files
authored
Merge pull request #1862 from Oktosha/views-intro
Django views — improve the intro paragraph
2 parents f72dfe3 + f036dd9 commit 45fc50e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

en/django_views/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
Time to get rid of the bug we created in the last chapter! :)
44

5-
A *view* is a place where we put the "logic" of our application. It will request information from the `model` you created before and pass it to a `template`. We'll create a template in the next chapter. Views are just Python functions that are a little bit more complicated than the ones we wrote in the __Introduction to Python__ chapter.
5+
A *view* is a place where we put the "logic" of our application. The views do the following:
6+
7+
1. Receive the `request` information (current user session and other stuff) as well as parameters parsed from the url (for example, the id of a blog post)
8+
2. Fetch the information from the `model`, probably adding some logic (like filtering logic to show only the published posts)
9+
3. Create a response by filling a `template` with the fetched info
10+
11+
We'll create a template in the next chapter. Now we'll create a view. Technically, views are Python functions, exactly like the ones we wrote in the __Introduction to Python__ chapter. These functions take `request` as a parameter and return `HttpResponse`. You shouldn't worry about the type of the return value because another function from the Django framework will construct it for us.
612

713
Views are placed in the `views.py` file. We will add our *views* to the `blog/views.py` file.
814

0 commit comments

Comments
 (0)