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 ... |
---|
Get Django: Web Development with Python 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.