I think what's happening is you are assigning a string to the 'login'
variable:

login = request.POST['login']

So when you get to:

login(request, user)

login is the text and not the function.

HTH,
Paulo

On Fri, Mar 19, 2010 at 3:15 PM, Martin Tiršel <dja...@blackpage.eu> wrote:

> Hello,
>
> can somebody help me with this error? I am a Django beginner but I don't
> see any errors in the code:
>
> Environment:
>
> Request Method: POST
> Request URL: http://127.0.0.1:8000/administration/
> Django Version: 1.1.1
> Python Version: 2.6.4
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'ibase.administration']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
>
> Traceback:
> File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in
> get_response
>  92.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File
> "/home/bruce/Projects/ibasedev/trunk/ibase/../ibase/administration/views.py"
> in login
>  23.                     login(request, user)
>
> Exception Type: TypeError at /administration/
> Exception Value: 'unicode' object is not callable
>
>
>
>
> Code:
>
> # -*- coding utf-8 -*-
>
> from django.contrib.auth import authenticate, login
> from django.shortcuts import render_to_response
> from ibase.administration.forms import LoginForm
>
> def login(request):
>    def error_handler(error):
>        form = LoginForm()
>        return render_to_response('pages/login.html', {
>            'error' : error,
>            'form' : form,
>        })
>
>    if request.method == 'POST':
>        form = LoginForm(request.POST)
>        if form.is_valid():
>            login = request.POST['login']
>            password = request.POST['password']
>            user = authenticate(username=login, password=password)
>            if user is not None:
>                if user.is_active:
>                    login(request, user)
>                    return render_to_response('pages/logged.html', {
>                        'login' : login,
>                    })
>                else:
>                    return error_handler(u'Account disabled')
>            else:
>                return error_handler(u'Invalid login or password')
>        else:
>            return error_handler(u'Invalid input')
>    else:
>        form = LoginForm()
>        return render_to_response('pages/login.html', {
>            'form' : form,
>        })
>
>
> Thanks,
> Martin
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to