Generic views
While working with Django, you will notice that there are certain types of views that are always needed regardless of the project you are working on. For this reason, Django comes with a set of views that can be used in any project. These views are known as generic views and we actually used one of them in a previous chapter. Remember the direct_to_template
view that renders a template into a page? This view is one example of generic views.
Django offers generic views for the following purposes:
Create simple views for tasks such as redirecting to another URL or rendering a template.
List view and detail view for displaying objects from a data model. These views are similar to how the admin page displays list and detail pages for the data models.
Views to generate date-based archive pages. These can be particularly useful for blogs.
Views for creating, editing, and deleting objects in data models.
To use one of these views, you import it from django.views.generic
and then map the...