Created
April 2, 2021 20:51
-
-
Save michaelhelmick/75e5f773dd89ee862e8ecb47ae6aad3d to your computer and use it in GitHub Desktop.
Bad example of views.py
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_serializer_class(self): | |
"""Determine serializer class.""" | |
if self.request.version == "1.1.0": | |
return TeeBallSupportedGameSerializer | |
elif self.request.version == "2.0.0": | |
return RevampedGameSerializer | |
return GameSerializer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment