[Answered ]-Many to many problem django

1👍

give title

category = Category.objects.get(title=title)
post_list = category.post_set.all()

return result

1👍

From the category objects you can retrieve the related objects using the automatically created field post_set, if the post model is named Post.

This is a bit tricky to find in the documentation because it is in a dedicated section, see here:
http://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships

0👍

Post.objects.all(catagory__title="My catagory title")?

👤jammon

Leave a comment