Skip to main content
Django Code Completion Hard +35 XP

Class-Based View

Complete to create a list view for the Post model.

DjangoFill in the blank
class PostListView(___): model = Post
    template_name = 'posts/list.html'

Type the missing code

Show answer and explanation

Answer: ListView

Django's generic ListView automatically queries all objects and passes them to the template as 'object_list' or the model name plural.

Hint: Which generic view lists all model objects?

What this challenge tests

Code Completion in Django: class-based-views, generic-views.

Related challenges