Esempio n. 1
0
File: views.py Progetto: salehi/xapi
 def put(self, request, pk, format=None):
     user = self.get_object(pk)
     serializer = UserSerializer(user, data=request.DATA)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
Esempio n. 2
0
File: views.py Progetto: salehi/xapi
 def post(self, request, format=None):
     user = UserSerializer(data=request.DATA)
     if user.is_valid():
         username, email, password = request.DATA['username'], request.DATA['email'], request.DATA['password']
         User.objects.create_user(username=username, password=password, email=email)
         return Response(request.DATA, status=status.HTTP_201_CREATED)
     return Response(user.errors, status=status.HTTP_400_BAD_REQUEST)