Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django assign authenticated user to foreign user

from rest_framework import generics, serializers
from rest_framework.permissions import IsAuthenticated

class TicketFormView(generics.CreateAPIView):
    serializer_class = TicketSerializer
    queryset = Ticket.objects.all()
    permission_classes = ( IsAuthenticated, )

    def perform_create(self, serializer):
        serializer.save(created_by=self.request.user)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #assign #authenticated #user #foreign #user
ADD COMMENT
Topic
Name
6+9 =