def login(request, template=None, next_url=None):
    feedback = ''
    action_url = '.'

    if request.session.keys() in 'user':
        # Redirect the user to the next desired page or to the site's root
        if next_url:
            return HttpResponseRedirect(next_url)
        else:
            return HttpResponseRedirect('/')
            
    try:
        if request.REQUEST['next_url']:
            next_url = request.REQUEST['next_url']
            action_url = '%s?next_url=%s' % (action_url, next_url)
    except:
        pass
    
    if request.method == "POST":
        form = LoginForm(request.POST)
        
        if form.is_valid():
            email = form.cleaned_data['email']
            password = form.cleaned_data['password']
            
            query = db.Query(User)
            user = query.filter('email =', email).get()
            
            if user:
                success = user.login(email=email, password=password, request=request)
                
                if success:
                    # Redirect the user to the next desired page or to the site's root
                    if next_url is not None:
                        return HttpResponseRedirect(next_url)
                    else:
                        return HttpResponseRedirect('/')
                else:
                    feedback = "Bad username and password.  Please try again."    
            else:
                feedback = "Bad username and password.  Please try again."
    else:
        form = LoginForm()    
        
    c = RequestContext(request, {
        'form':form,
        'feedback':feedback,
        'action_url':action_url,
    })
    
    if template is None:
        template = 'login.html'
    
    return render_to_response(template, c)
dataset/ETHPy150Open bgolub/fftogo/django_ae_utils/auth/views.py/login/swapped operands of `in`