O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.5 Re-creating PostDetail with DateDetailView

In 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required