From f036dd939a2086ba949d644d2b373958ca3e62d7 Mon Sep 17 00:00:00 2001 From: Daria Kolodzey Date: Tue, 11 Mar 2025 18:46:41 +0100 Subject: [PATCH] =?UTF-8?q?Django=20views=20=E2=80=94=20improve=20the=20in?= =?UTF-8?q?tro=20paragraph?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- en/django_views/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/en/django_views/README.md b/en/django_views/README.md index fe20ba7bb7d..4c0d860c6d9 100644 --- a/en/django_views/README.md +++ b/en/django_views/README.md @@ -2,7 +2,13 @@ Time to get rid of the bug we created in the last chapter! :) -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. +A *view* is a place where we put the "logic" of our application. The views do the following: + +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) +2. Fetch the information from the `model`, probably adding some logic (like filtering logic to show only the published posts) +3. Create a response by filling a `template` with the fetched info + +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. Views are placed in the `views.py` file. We will add our *views* to the `blog/views.py` file.