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

5.8.6 Building a Post Detail Page

The final view left to program is our detail view of a single Post object. Programming the view and URL pattern for this view is a little bit trickier than our other views: the URL for each Post object is based not only on the slug but also on the date of the object, making the regular expression pattern and query to the database a little more complicated. Recall that we are enforcing this behavior in our Post model via the unique_for_month attribute on the slug.

Take http://site.django-unleashed.com/blog/2013/1/django-training/ as an example. After include() in our root URL configuration truncates blog/ from the URL path, our blog app URL configuration will receive 2013/1/django-training/. Our regular expression ...

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