i am getting this error. i am trying to loop through posts to display the posts that are part of the collection. What should i change this to?
relevant info:
models.py
class Collection(models.Model):
posts = models.ManyToManyField(Post, related_name='collection_posts', null=True, blank=True)
views.py
def collection_detail_view(request, pk):
collection = Collection.objects.get(id=pk)
posts = Collection.posts.all() #this is the error
context = {
'collection': collection,
'posts': posts
}
return render(request, 'collection_detail.html', context)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…