from rest_framework import viewsets
from . import serializers, models


class PrintJobViewSet(viewsets.ModelViewSet):
    serializer_class = serializers.PrintJobSerializer

    def get_queryset(self):
        return self.request.user.printjobs.all()

from rest_framework import viewsets
from . import serializers, models


class PrintJobViewSet(viewsets.ModelViewSet):
    serializer_class = serializers.PrintJobSerializer

    def get_queryset(self):
        return self.request.user.printjobs.all()

    def perform_create(self, serializer):
        # need to also pass the requests user on a create
        serializer.save(user=self.request.user)

Add user to posted print object
Add user to posted print object

  from rest_framework import viewsets
  from . import serializers, models
  
  
  class PrintJobViewSet(viewsets.ModelViewSet):
      serializer_class = serializers.PrintJobSerializer
  
      def get_queryset(self):
          return self.request.user.printjobs.all()
  
+     def perform_create(self, serializer):
+         # need to also pass the requests user on a create
+         serializer.save(user=self.request.user)
+ 
Add user to posted print object
## Code Before:
from rest_framework import viewsets
from . import serializers, models


class PrintJobViewSet(viewsets.ModelViewSet):
    serializer_class = serializers.PrintJobSerializer

    def get_queryset(self):
        return self.request.user.printjobs.all()

## Instruction:
Add user to posted print object
## Code After:
from rest_framework import viewsets
from . import serializers, models


class PrintJobViewSet(viewsets.ModelViewSet):
    serializer_class = serializers.PrintJobSerializer

    def get_queryset(self):
        return self.request.user.printjobs.all()

    def perform_create(self, serializer):
        # need to also pass the requests user on a create
        serializer.save(user=self.request.user)
