Anyone?

On Sep 9, 5:47 pm, MikeHowarth <[EMAIL PROTECTED]> wrote:
> Hi guys
>
> Was wondering if anyone knew of any bugs within the user
> authentication system associated to setting the backend attribute?
>
> Basically looking at the traceback the user object expects a attribute
> 'backend' to be set within however this doesn not seem to be set.
>
> Traceback:
>
> Traceback (most recent call last):
> File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
> get_response
>   77. response = callback(request, *callback_args, **callback_kwargs)
> File "D:\Web Dev\Test\eshop\..\eshop\login\views.py" in login
>   10. if loginform.login(request):
> File "D:\Web Dev\Test\eshop\..\eshop\login\forms.py" in login
>   56. login(request, self.user)
> File "C:\Python25\lib\site-packages\django\contrib\auth\__init__.py"
> in login
>   53. request.session[BACKEND_SESSION_KEY] = user.backend
>
>   AttributeError at /login/
>   'User' object has no attribute 'backend'
>
> Forms.py
>
> class LoginForm(forms.Form):
>
>         username = forms.CharField(label=_('username'))
>         password = forms.CharField(label=_('password'))
>         user = None   # allow access to user object
>
>         def clean(self):
>
>             # only do further checks if the rest was valid
>             if self._errors: return
>
>             from django.contrib.auth import login, authenticate
>
>             user = authenticate(username=self.data['username'],
>                                 password=self.data['password'])
>
>             if user is not None:
>                 if user.is_active:
>                     self.user = user
>                 else:
>                     raise forms.ValidationError(ugettext(
>                         'This account is currently inactive. Please
> contact '
>                         'the administrator if you believe this to be
> in error.'))
>             else:
>                 raise forms.ValidationError(ugettext(
>                     'The username and password you specified are not
> valid.'))
>
>         def login(self, request):
>
>             from django.contrib.auth import login
>
>             if self.is_valid():
>                 login(request, self.user)
>                 return True
>             return False


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

Reply via email to