Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Post List View | Templates
Django: First Dive
course content

Kursusindhold

Django: First Dive

Django: First Dive

1. Get Started
2. Write the First Page
3. Models
4. Working with Database
5. Templates
6. Request Handling

book
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:

html

We implemented the post_list view function:

python

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 the Submit Task button to solve this task.

Opgave

Swipe to start coding

  1. Rewrite the post_list function using the render() 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.
  2. The context dictionary should contain the "post" key with the iterable QuerySet of posts.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 5. Kapitel 3
toggle bottom row

book
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:

html

We implemented the post_list view function:

python

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 the Submit Task button to solve this task.

Opgave

Swipe to start coding

  1. Rewrite the post_list function using the render() 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.
  2. The context dictionary should contain the "post" key with the iterable QuerySet of posts.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 5. Kapitel 3
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt