title: How to change my code for methods in the APIView to be called in the right order?
body: <p>I am implementing an API for a game using DRF view (more specifically APIViews). I have figured out how to use more than one serializer for a view but I need this view to combine multiple models and think that I need more than one GET as well as more than one POST method. Is this even possible? My code so far looks like this:</p>
  <pre><code>class GameView(APIView):
      &quot;&quot;&quot;
      API View that retrieves the game,
      retrieves an empty game session to be filled with the necessary data and sent back to the server
      retrieves a random resource per round
      allows users to post tags that are verified and saved accordingly to either the Label or VerifiedLabel table
      &quot;&quot;&quot;
      renderer_classes = (BrowsableAPIRenderer, JSONRenderer, HTMLFormRenderer)
      controller = GameViewController()
  
      def get_serializer_class(self):
          YOUR_DEFAULT_SERIALIZER = GametypeSerializer
          YOUR_SERIALIZER_1 = GamesessionSerializer
          YOUR_SERIALIZER_2 = GameroundSerializer
          YOUR_SERIALIZER_3 = ResourceSerializer
          YOUR_SERIALIZER_4 = VerifiedLabelSerializer
          YOUR_SERIALIZER_5 = LabelSerializer
  
          if self.request.method == 'POST':
              return YOUR_SERIALIZER_4 and YOUR_SERIALIZER_5 and YOUR_SERIALIZER_1
          elif self.request.method == 'GET':
              return YOUR_SERIALIZER_2 and YOUR_SERIALIZER_3
          else:
              return YOUR_DEFAULT_SERIALIZER
  
      def get_queryset(self):
          &quot;&quot;&quot;
  
          :return:
          &quot;&quot;&quot;
          obj = None
          resources = None
          chosen_gametype = None
          gameround = None
          gamesession = None
  
          while obj is None:
              if obj == resources:
                  while resources is None:
                      random_idx = random.randint(0, Resource.objects.count() - 1)
                      resources = Resource.objects.all().filter(id=random_idx)
                      obj = resources
  
              elif obj == chosen_gametype:
                  while chosen_gametype is None:
                      chosen_gametype = Gametype.objects.all().filter(name=&quot;imageLabeler&quot;)
                      obj = chosen_gametype
  
              elif obj == gamesession:
                  while gamesession is None:
                      # TODO: figure out how to send empty gamesession
                      gamesession = Gamesession.objects.none()
                      obj = gamesession
  
              elif obj == gameround:
                  while gameround is None:
                      # TODO: figure out how to send empty gameround
                      gameround = Gameround.objects.none()
                      obj = gameround
  
          return obj
  
      def get(self, request, *args, **kwargs):
          &quot;&quot;&quot;
  
          :param request:
          :param args:
          :param kwargs:
          :return:
          &quot;&quot;&quot;
          model = request.GET.get(&quot;model&quot;)
          serializer = None
          # TODO: find way to assign what model is?
          model = &quot;Gametype&quot;  # For testing purposes only!
          while serializer is None:
  
              if model == &quot;Gametype&quot;:
                  gametype = self.get_queryset()
                  serializer = GametypeSerializer(gametype, many=True)
                  resource = self.get_queryset()
                  serializer = ResourceSerializer(resource, many=True)
  
              elif model == &quot;Gameround&quot;:
                  gameround = Gameround.objects.none()
                  serializer = GameroundSerializer(gameround, many=True)
  
              elif model == &quot;Gamesession&quot;:
                  gamesession = Gamesession.objects.none()
                  serializer = GamesessionSerializer(gamesession, many=True)
  
          return Response(serializer.data)
  
      def post(self, request, *args, **kwargs):
          &quot;&quot;&quot;
  
          :param request:
          :param args:
          :param kwargs:
          :return:
          &quot;&quot;&quot;
          saved_gameround = None
          saved_gamesession = None
          saved_label = None
          saved_verified_label = None
          saved_obj = None
  
          model = request.GET.get(&quot;model&quot;)
          model = &quot;Label&quot;
  
          if model == &quot;Gameround&quot;:
              gameround = GameroundSerializer(data=request.data)
              while saved_gameround is None:
                  serializer = GameroundSerializer(data=gameround)
                  if serializer.is_valid(raise_exception=True):
                      saved_gameround = serializer.save()
                      saved_obj = saved_gameround
                      return Response(saved_obj, status=status.HTTP_201_CREATED)
  
          elif model == &quot;Gamesession&quot;:
              gamesession = request.data.get_queryset()
              while saved_gamesession is None:
                  serializer = GamesessionSerializer(data=gamesession)
                  if serializer.is_valid(raise_exception=True):
                      saved_gamesession = serializer.save()
                      saved_obj = saved_gamesession
                      return Response(saved_obj, status=status.HTTP_201_CREATED)
          elif model == &quot;Label&quot;:
              # test &amp; modify if necessary
              label = serializer.ResourceWithTaggingsSerializer(data=request.data)
              while saved_label is None:
                  serializer = ResourceWithTaggingsSerializer(data=tagging)
                  if serializer.is_valid(raise_exception=True):
                      saved_label = serializer.save()
                      saved_obj = saved_label
                      return Response(saved_obj, status=status.HTTP_201_CREATED)
  
          elif model == &quot;VerifiedLabel&quot;:
              # TODO: add condition to only save to tag if condition met
              # tag = request.data.get_queryset()
              verified_label = serializer.ResourceWithTagsSerializer(data=request.data)
              while saved_verified_label is None:
                  serializer = ResourceWithTagsSerializer(data=verified_label)
                  if serializer.is_valid(raise_exception=True):
                      saved_verified_label = serializer.save()
                      saved_obj = saved_verified_label
                      return Response(saved_obj, status=status.HTTP_201_CREATED)
  
          return Response(saved_obj, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  <p>I think it is worth mentioning that I plan on using a single url for this. It should work like this: a user clicks a game type and then this view is called and the game starts and everything is handled that needs to be handled during the game.
  *I have set model = &quot;Model&quot; to test. I am looking for a way to do this differently.</p>