Generic View? What is that and why would I use it?
summary
Explains exactly how Django implements generic class‑based views: as_view returns a function that instantiates the class, calls setup method added in Django 2.2, and dispatches to get/post methods; dispatch validates HTTP methods and calls the handler. Shows concrete generics: CreateView = set template_name + form_class, ListView supports pagination, DetailView reads the instance via pk_url_kwarg 'pk'. Includes an example repo, a working multi‑form view that later proves hard to maintain, and guidelines when to subclass or prefer simple views.
AI-written summary · about
chapters (43)
- 0:00Introduction
- 2:14History
- 3:21How do we implement classbased views
- 4:11Example of URL with function
- 10:40Sample Use Case
- 12:08Pros Cons
- 14:47Generic View Internals
- 22:57Quick Pause
- 23:43Context Mixin
- 24:33GetContextData
- 26:05TemplateResponseMixin
- 26:17Render to Response
- 26:47Template View
- 27:28Template View Example
- 28:00Redirect View
- 28:12Rename URL
- 28:50List View
- 29:23List to List
- 29:39ListView
- 30:06GetQuerySet
- 30:51DetailView
- 31:10Object
- 31:48Details
- 32:01How it works
- 32:15Why it works
- 32:43Form View
- 34:14Form Handling
- 34:43Get Form
- 35:54Get Form Cards
- 36:19Form Valid
- 36:45Create View
- 37:31Detail View
- 39:32List View Demo
- 40:45Generic View Guidelines
- 41:33Overrides
- 41:56Classbased views
- 43:06Mixins
- 43:38Creating your own
- 44:18When I first started
- 45:19Make sure to think through
- 46:25Classbased view
- 47:13Recap
- 47:50Resources
related talks
40mClass-based Views: Past, Present and Future
40mClass-based Views: Past, Present and Future
27mThe Beauty of ViewSets in Django Rest Framework
29mSleeping with the enemy..
24mDemystifying Mixins with Django
27mGood form: How Django’s form rendering improved during the 4.x series
30mThe Wizardry of Metaprogramming
23mA different Form of navigation
