Guest User

Untitled

a guest
Aug 5th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. How to prevent jquery mobile from handling post request with ajax in django
  2. def login(request):
  3. if request.method == 'POST':
  4. username = request.POST['u']
  5. password = request.POST['p']
  6. user = authenticate(username=username, password=password)
  7. if user is not None:
  8. if user.is_active:
  9. auth_login(request, user)
  10. msg.append("Hello %s your login was successful"% username)
  11. return HttpResponseRedirect('/profile/')
  12. else:
  13. msg.append("disabled account")
  14. else:
  15. msg.append("invalid login")
  16.  
  17. return render_to_response('login.html')
  18.  
  19. {% block content %}
  20.  
  21. <form action="" method="post">{% csrf_token %}
  22. Login:&nbsp; <input type="text" name="u">
  23. <br/>
  24. Password:&nbsp; <input type="password" name="p">
  25. <input type="submit" value="Login">
  26. </form>
  27. {% if errors %}
  28. <ul>
  29. {% for error in errors %}
  30. <li>{{ error }}</li>
  31. {% endfor %}
  32. </ul>
  33. {% endif %}
  34. <a href="logout"> Logout </a>
  35.  
  36. {% endblock %}
  37.  
  38. <script type="text/javascript">
  39. $(document).bind("mobileinit", function(){
  40. ajaxEnabled:false;
  41. });
  42. </script>
Add Comment
Please, Sign In to add comment