#views.py
def login(request):
ctx=dict()
ctx['login_form'] = LoginForm()
if request.method == 'POST':
for e in Login.objects.all():
if e.password==request.POST['password']:
redirect_to('my url')
return HttpResponse('failed authentication ')
return render_to_response('registration/login.html', ctx, context_instance = RequestContext(request))
#urls.py
urlpatterns = patterns('',
(r'^signup/', signup),
(r'^$', index),
(r'^ajaxsite/', signup),
(r'^login/', login),
)
问问题
81 次
1 回答
2
使用重定向https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#redirect
return redirect(new_url)
或者如果是 ajax 提交,
return HttpResponseRedirect(new_url)
于 2012-08-30T14:49:17.760 回答