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

27.3.1 Displaying Related Posts

The goal is to build a template tag that allows us to quickly and easily print the blog posts of any related object. Our final custom template tag is a bit complex, so we start with a very simple tag.

The goal is to first load our template tag via Example 27.5.

Example 27.5: Project Code

organizer/templates/organizer/startup_detail.html in 573488aa97

3   {% load partial_post_list %}

We then replace the entirety of the template to print related blog posts in startup_detail.html with the code in Example 27.6.

Example 27.6: Project Code

organizer/templates/organizer/startup_detail.html in 573488aa97

118         {% if perms.blog.view_future_post and startup.blog_posts.all ...

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