Last active
April 2, 2021 20:44
-
-
Save michaelhelmick/6503d3d134dc9e5fe9988704809b415d to your computer and use it in GitHub Desktop.
Bad example
This file contains 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
from rest_framework import viewsets | |
class GameViewSet(viewsets.ReadOnlyModelViewSet): | |
"""Game viewset.""" | |
queryset = Game.objects.all() | |
serializer_class = GameSerializer | |
def get_queryset(self): | |
"""Filter class queryset.""" | |
if self.action == "list": | |
if self.request.version != Game.TEEBALL_INTRODUCED_VERSION: | |
self.queryset = self.queryset.exclude(type=Game.GameType.TEEBALL) | |
return self.queryset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment