Answers for "object all orders django"

1

django order by

Entry.objects.filter(pub_date__year=2005).order_by('-pub_date', 'headline')
Posted by: Guest on June-12-2020
0

get queryset

class PurchaseList(generics.ListAPIView):
    serializer_class = PurchaseSerializer

    def get_queryset(self):
        """
        Optionally restricts the returned purchases to a given user,
        by filtering against a `username` query parameter in the URL.
        """
        queryset = Purchase.objects.all()
        username = self.request.query_params.get('username', None)
        if username is not None:
            queryset = queryset.filter(purchaser__username=username)
        return queryset
Posted by: Guest on July-31-2020

Python Answers by Framework

Browse Popular Code Answers by Language