17.5.3 Returning to Redirection
In Chapter 5 we built a view to redirect our root URL to our blog post list. This view, thanks to GCBVs, is completely unnecessary. We therefore replace the view and the URL pattern with the RedirectView
GCBV.
To start, delete the suorganizer/views.py
file. In suorganizer/urls.py
, replace the URL pattern referencing redirect_root
with the code in Example 17.31.
suorganizer/urls.py
in b02e39dac0
20 from django.views.generic import RedirectView . ... 29 url(r'^$', 30 RedirectView.as_view( 31 pattern_name='blog_post_list', 32 permanent=False)),
Thanks to the ability to override CBV attributes and the behavior ...
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.