17.2.1 Converting to Class-Based Views
We need to convert the function views for Startup
detail and Tag
detail into class-based views.
For Tag
, use the code in Example 17.1.
organizer/views.py
in 2dfd449f41
162 class TagDetail(View): 163 164 def get(self, request, slug): 165 tag = get_object_or_404( 166 Tag, slug--iexact=slug) 167 return render( 168 request, 169 'organizer/tag_detail.html', 170 {'tag': tag})
For Startup
, use the code in Example 17.2.
organizer/views.py
in 2dfd449f41
89 class StartupDetail(View): 90 91 def get(self, request, ...
Get Django Unleashed 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.