[Answered ]-Django, warning as VIEW return queryset unordered

1๐Ÿ‘

โœ…

As you override the get_queryset method and do not order the queryset, Django shows the warning.

You can solve this by @Eric Martin commented link
or follow the following solution

def get_queryset(self, *args, **kwargs):
    queryset = super(PostListView, self).get_queryset()
    district = self.kwargs.get('district')
    catagory = self.kwargs.get('catagory')
    if district !=False:
        posts = queryset.filter(Q(catagory=catagory)& Q(district=district))
    else:
        posts = queryset.filter(catagory=catagory)                              
    return posts 
๐Ÿ‘คshafikshaon

Leave a comment