20.6 Displaying Future Posts in the Template

When we created the AllowFuturePermissionMixin class, we successfully limited the Post views to only display future blog posts to users with the blog.view_future_post permission. However, we have Post objects listed in the tag_detail.html and startup_detail.html templates, and these are not using the permission system.

In the template, we therefore create a condition to check whether the user has the permission and the display either all of the posts or all of the published posts. By design, the template system cannot pass arguments to methods. We therefore cannot create a queryset for published posts in the template, and nor would we want to, given the philosophy of “fat models, thin templates.” ...

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.