Class-based generic views
Class-based generic views are commonly used views implemented in an object-oriented manner (Template method pattern) for better reuse. I hate the term generic views. I would rather call them stock views. Like stock photographs, you can use them for many common needs with a bit of tweaking.
Generic views were created because Django developers felt that they were recreating the same kind of views in every project. Nearly every project needed a page showing a list of objects (ListView
), details of an object (DetailView
), or a form to create an object (CreateView
). In the spirit of DRY, these reusable views were bundled with Django.
A convenient table of generic views in Django 1.7 is given here:
Type |
Class Name |
Description |
---|---|---|
Base |
|
This is the parent of all views. It performs dispatch and sanity checks. |
Base |
|
This renders a template. It exposes the |
Base |
|
This redirects on any |
List... |