Course Content
Django: First Dive
Django: First Dive
2. Write the First Page
4. Working with Database
Post List View
Now, let's create the post_list.html
file inside the template folder.
For now, the HTML file should be the following structure:
We implemented the post_list
view function:
Note
The presented code for the task is part of the framework and cannot work separately, so errors will be received when you try to
Run Code
. Use theSubmit Task
button to solve this task.
Task
- Rewrite the
post_list
function using therender()
function. The render function should:- Receive the
request
as the first argument. - Receive the
post_list.html
template name as the second argument. - Receive the
context
dictionary as the third argument.
- Receive the
- The
context
dictionary should contain the"post"
key with the iterable QuerySet of posts.
Task
- Rewrite the
post_list
function using therender()
function. The render function should:- Receive the
request
as the first argument. - Receive the
post_list.html
template name as the second argument. - Receive the
context
dictionary as the third argument.
- Receive the
- The
context
dictionary should contain the"post"
key with the iterable QuerySet of posts.
Everything was clear?
Post List View
Now, let's create the post_list.html
file inside the template folder.
For now, the HTML file should be the following structure:
We implemented the post_list
view function:
Note
The presented code for the task is part of the framework and cannot work separately, so errors will be received when you try to
Run Code
. Use theSubmit Task
button to solve this task.
Task
- Rewrite the
post_list
function using therender()
function. The render function should:- Receive the
request
as the first argument. - Receive the
post_list.html
template name as the second argument. - Receive the
context
dictionary as the third argument.
- Receive the
- The
context
dictionary should contain the"post"
key with the iterable QuerySet of posts.
Task
- Rewrite the
post_list
function using therender()
function. The render function should:- Receive the
request
as the first argument. - Receive the
post_list.html
template name as the second argument. - Receive the
context
dictionary as the third argument.
- Receive the
- The
context
dictionary should contain the"post"
key with the iterable QuerySet of posts.
Everything was clear?
Post List View
Now, let's create the post_list.html
file inside the template folder.
For now, the HTML file should be the following structure:
We implemented the post_list
view function:
Note
The presented code for the task is part of the framework and cannot work separately, so errors will be received when you try to
Run Code
. Use theSubmit Task
button to solve this task.
Task
- Rewrite the
post_list
function using therender()
function. The render function should:- Receive the
request
as the first argument. - Receive the
post_list.html
template name as the second argument. - Receive the
context
dictionary as the third argument.
- Receive the
- The
context
dictionary should contain the"post"
key with the iterable QuerySet of posts.
Task
- Rewrite the
post_list
function using therender()
function. The render function should:- Receive the
request
as the first argument. - Receive the
post_list.html
template name as the second argument. - Receive the
context
dictionary as the third argument.
- Receive the
- The
context
dictionary should contain the"post"
key with the iterable QuerySet of posts.
Everything was clear?
Now, let's create the post_list.html
file inside the template folder.
For now, the HTML file should be the following structure:
We implemented the post_list
view function:
Note
The presented code for the task is part of the framework and cannot work separately, so errors will be received when you try to
Run Code
. Use theSubmit Task
button to solve this task.
Task
- Rewrite the
post_list
function using therender()
function. The render function should:- Receive the
request
as the first argument. - Receive the
post_list.html
template name as the second argument. - Receive the
context
dictionary as the third argument.
- Receive the
- The
context
dictionary should contain the"post"
key with the iterable QuerySet of posts.