Guest User

Untitled

a guest
Jan 15th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. from django.conf.urls.defaults import patterns, include, url
  2. import myproject.views
  3.  
  4. urlpatterns = patterns('', (r'^$', myproject.views.home), (r'^login$', apolla.views.login))
  5.  
  6. import django.http
  7. import django.template
  8. import django.shortcuts
  9.  
  10. def home(request):
  11. return django.http.HttpResponse("Welcome home!")
  12.  
  13. def login(request):
  14. un = request.POST.get('username')
  15. pa = request.POST.get('password')
  16. di = {'unam': un, 'pass': pa}
  17. if un and pa:
  18. di['act'] = "/"
  19. else:
  20. di['act'] = "/login"
  21. return django.shortcuts.render_to_response('login.html', di,
  22. context_instance=django.template.RequestContext(request))
  23. # Why does this code not send me immediately to "/" with
  24. # username and password filled in?
  25.  
  26. <html>
  27. <head>
  28. </head>
  29. <body>
  30. <form name="input" method="post" action="{{ act }}">
  31. {% csrf_token %}
  32. Username:
  33. <input type="text" name="username"><br>
  34. Password:
  35. <input type="password" name="password"><br>
  36. <input id="su" type="submit" value="Submit"><br>
  37. </form>
  38. </body>
  39. </html>
  40.  
  41. from django.http import HttpResponseRedirect
  42.  
  43. def foo_view(request):
  44. # ...
  45. return HttpResponseRedirect('/')
Add Comment
Please, Sign In to add comment