Exemplo n.º 1
0
 def post(request):
     serializer = UserSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         data = dict(status="Success!")
         return Response(data=data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors, status=400)
Exemplo n.º 2
0
 def create(self, request, *args, **kwargs):
     group = Group.objects.filter(name='candidates')
     user_serializer = UserSerializer(data=request.data)
     user_serializer.is_valid(raise_exception=True)
     user = user_serializer.save(groups=group)
     return Response({'id': user.pk}, status=status.HTTP_201_CREATED)