5.9 Class-Based Views
Warning!
This section deals with Python methods and HTTP methods. I will refer to Python methods simply as methods and to HTTP methods as HTTP methods, typically referring to the actual HTTP method in capitals (such as the HTTP GET method or the HTTP OPTIONS method).
Any Python callable that accepts an HttpRequest object as argument and returns an HttpResponse object is deemed a view in Django. So far, we’ve stuck exclusively to using Python functions to create views. Prior to Django 1.3, this was the only recommended way to create views. However, starting in version 1.3, Django introduced a class to allow developers to create view objects.
Django introduced a class to create view objects because coding the class for ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access