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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.