11
Advanced Templating and Class-Based Views
In Chapter 3, URL Mapping, Views, and Templates, we learned how to build views and create templates in Django. Then, we learned how to use those views to render the templates we built. In this chapter, we will build upon our knowledge of developing views by using class-based views, allowing us to write views that can group logical methods into a single entity. This skill comes in handy when developing a view that maps to multiple HTTP request methods for the same application programming interface (API) endpoint. With method-based views, we may end up using a lot of the if-else conditions to successfully handle the different types of HTTP request methods. In contrast, class-based views allow us to ...
Get Web Development with Django - Second Edition 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.