Last active
February 27, 2023 14:34
-
-
Save carvalhochris/bb06b1ed5f882287845bab824bf94757 to your computer and use it in GitHub Desktop.
Django Rest Viewset sort by pinned, then by year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WorkViewSet(viewsets.ModelViewSet): | |
| queryset = Work.objects.all() | |
| serializer_class = WorkSerializer | |
| def get_queryset(self): | |
| queryset = Work.objects.order_by('-pinned', '-year') | |
| return queryset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment