开发者

Django forms always failing

I'm trying to use Django's built in authentication modules. For the site I'm working on I want to use email addresses as login names and not just the normal alphanumeric fields they're usually set to. In order to do this I changed all the String fields to Email fields and changed their max length from 30 to 320. My registration code appears to be working fine but not my login code. Here is what I'm using right n开发者_如何学JAVAow:

def login(request):
    if request.method == 'POST':
        form = AuthenticationForm(request.POST)
        if form.is_valid():
            return HttpResponse("valid")
            username = request.POST['username']
            password = request.POST['password']
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponseRedirect("/")
                    # Redirect to a success page.
                else:
                    return HttpResponse("Disabled Account")
                    # Return a 'disabled account' error message
            else:
                return HttpResponse("Invalid Login")
                # Return an 'invalid login' error message.
        else:
            return HttpResponse("%s" % repr(form.errors))
    else:
        form = AuthenticationForm()

    return render_to_response("login.html",  {'form': form,  }, context_instance=RequestContext(request))

No matter what I submit, form.is_valid() is returning FALSE but form.errors is empty. Any ideas what might be wrong? I think I changed everything over to Email properties so I don't think that's it. Also, in case it changes anything I'm trying to do this on google app engine using djangoappengine.


Sorry, but you cannot use Django's authentication module on top of google app engine. Django uses its own special database backend which is similar to google-app-engine's but is not drop-in compatible.

If you want to do authentication on GAE, you should do it the google-app-engine way: http://code.google.com/appengine/docs/python/users/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜