17.5.2 Blog Views

To begin, we can change the inheritance in PostCreate and PostList to use CreateView and ListView, removing all of the methods from those classes, and leaving the attributes as is, as shown in Example 17.30.

Example 17.30: Project Code

blog/views.py in 18cf8cb4ed

 5   from django.views.generic import (  6       CreateView, ListView, View)  .       ... 12   class PostCreate(CreateView): 13       form_class = PostForm 14       model = Post  .       ... 53   class PostList(ListView): 54       model = Post

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.