Answers for "django order filter"

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

from myapp.models import Purchase
from myapp.serializers import PurchaseSerializer
from rest_framework import generics

class PurchaseList(generics.ListAPIView):
    serializer_class = PurchaseSerializer

    def get_queryset(self):
        """
        This view should return a list of all the purchases
        for the currently authenticated user.
        """
        user = self.request.user
        return Purchase.objects.filter(purchaser=user)
Posted by: Guest on July-31-2020

Python Answers by Framework

Browse Popular Code Answers by Language