Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.conf.urls.defaults import patterns, include, url
- import myproject.views
- urlpatterns = patterns('', (r'^$', myproject.views.home), (r'^login$', apolla.views.login))
- import django.http
- import django.template
- import django.shortcuts
- def home(request):
- return django.http.HttpResponse("Welcome home!")
- def login(request):
- un = request.POST.get('username')
- pa = request.POST.get('password')
- di = {'unam': un, 'pass': pa}
- if un and pa:
- di['act'] = "/"
- else:
- di['act'] = "/login"
- return django.shortcuts.render_to_response('login.html', di,
- context_instance=django.template.RequestContext(request))
- # Why does this code not send me immediately to "/" with
- # username and password filled in?
- <html>
- <head>
- </head>
- <body>
- <form name="input" method="post" action="{{ act }}">
- {% csrf_token %}
- Username:
- <input type="text" name="username"><br>
- Password:
- <input type="password" name="password"><br>
- <input id="su" type="submit" value="Submit"><br>
- </form>
- </body>
- </html>
- from django.http import HttpResponseRedirect
- def foo_view(request):
- # ...
- return HttpResponseRedirect('/')
Add Comment
Please, Sign In to add comment