November 2015
Beginner to intermediate
840 pages
26h 30m
English
PostDetail with DateDetailViewIn Chapter 17, we used DetailView to replace the behavior of displaying an object in TagDetail and StartupDetail, but we left post_detail() alone. DetailView works only with URL patterns that use a pk, a slug, or both (starting in Django 1.8). Given that our detail page for Post uses the year, month, and slug of the object for uniqueness, it didn’t make any sense to use TagDetail.
Django provides a GCBV called DateDetailView to work with objects that have uniqueness according to a DateField, much in the spirit of ArchiveIndexView or YearArchiveView. The catch is that the GCBV anticipates using the full date: the year, month, and day (on top of the slug). In this section, we not only switch to using ...
Read now
Unlock full access