Guest User

Untitled

a guest
Jan 15th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. parsed_json = json.loads(request.body)
  2.  
  3. $("#add_user_button").click(function (event) {
  4. event.preventDefault();
  5. $.ajax({
  6. type: "POST",
  7. url: '/user/',
  8. data:
  9. {
  10. 'action': "addUser",
  11. 'username': $('#id_username').val(),
  12. 'password': $('#id_password').val(),
  13. 'groups': $('#id_groups').val()
  14. }
  15. ,
  16. contentType: 'application/json; charset=utf-8',
  17. processData: false,
  18. });
  19. }
  20.  
  21. print(request.POST.get("username"))
  22. #print(request.encoding) #returns none
  23. print("Request body is :")
  24. print(request.body)
  25. print(type(request.body))
  26.  
  27. hello
  28. Request body is :
  29. b'username=hello&password=world&csrfmiddlewaretoken=&addUser=Add+User'
  30. <class 'bytes'>
Add Comment
Please, Sign In to add comment