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

Get Django Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.