Side note: When posting code, templates, error messages, etc here, enclose it between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code (templates, etc), then another line of ```. This forces the forum software to keep your code properly formatted.
You’re directly referencing the related object manager “all” here - this is going to issue a query to retrieve all related Post. (Most importantly, it’s not going to use the other query you’ve defined on Post.)
There are a couple different ways to address this. It’s up to you to decide which approach works best for you.
Create a model method in Category to retrieve the latest three Post, and iterate over it in your template.
If you’re using PostgreSQL, you could use the ArrayAgg function to annotate the list of the latest three Post in Category, and iterate over that list
Perform your query on Post and reorganize the data within your view before sending it to the template.