-2
#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),

)
4

1 に答える 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 に答える