2👍
You should define the get_queryset
method instead of the standalone queryset
attribute.
def get_queryset(self, *args, **kwargs):
return Comment.objects.filter(chat_id=self.kwargs['pk'])
0👍
Instead of CommentList
you can use plain view:
def comments_index(request, chatid):
return render(request, 'xxx/comment_list.html', {
'comments': Comment.objects.filter(chat_id=chatid)
})
And in urls:
url(r'^comments/(?P<chatid>[0-9]+)/$', views.comments_index, name='comments'),
- [Answered ]-Writable nested Django serializer with string instead of dict
- [Answered ]-How can I create simple Django chat based on WebSockets with PostgreSQL database?
- [Answered ]-Special characters in filenames and paths
- [Answered ]-Django url multiple parameter
- [Answered ]-How to get the Azure Webapp App Settings from Django
Source:stackexchange.com