0
When I create two topics with the same name, error:Multipleobjectsreturned
class ForumView(ListView):
paginate_by = 5
template_name = 'forum/forum.html'
def get_queryset(self):
queryset = Thread.objects.filter()
order = self.request.GET.get('order','')
if order == 'views':
queryset = queryset.order_by('-views')
elif order == 'answers':
queryset = queryset.order_by('-answers')
return queryset
How to change the query to avoid error with thread of the same name?
What is the stack trace of the exception?
– lvella
Try replacing Filter() with all() or pass some argument to filter()
– Pedro Henrique Silva
In which line does the error occur? Posting stackTrace would help a lot, as @Ivella suggested
– luislhl