If this is an accurate representation of the template, then you’ve got a couple of likely issues here.
First, you’re missing the space in post.pk%}
.
Second, you’ve got the {% for category ...
tag split across lines.
The template rendering engine is extremely picky when it comes to syntax of tags, filters, etc. Spaces and linefeeds are critical.
In particular, see #8652 (Multiline tags and tag escape tags) – Django.