Advertisement
Guest User

Untitled

a guest
Mar 12th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. "detail": "CSRF Failed: CSRF token missing or incorrect."
  2.  
  3. class RegistrationView(APIView):
  4. """ Allow registration of new users. """
  5. permission_classes = (permissions.AllowAny,)
  6.  
  7. def post(self, request):
  8. serializer = RegistrationSerializer(data=request.DATA)
  9.  
  10. # Check format and unique constraint
  11. if not serializer.is_valid():
  12. return Response(serializer.errors,
  13. status=status.HTTP_400_BAD_REQUEST)
  14. data = serializer.data
  15.  
  16. # u = User.objects.create_user(username=data['username'],
  17. # email=data['email'],
  18. # password='password')
  19.  
  20. u = User.objects.create(username=data['username'])
  21. u.set_password(data['password'])
  22. u.save()
  23.  
  24. # Create OAuth2 client
  25. name = u.username
  26. client = Client(user=u, name=name, url='' + name,
  27. client_id=name, client_secret='', client_type=1)
  28. client.save()
  29. return Response(serializer.data, status=status.HTTP_201_CREATED)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement