'AnonymousUser'对象没有属性'backend' [英] 'AnonymousUser' object has no attribute 'backend'

查看:60
本文介绍了'AnonymousUser'对象没有属性'backend'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用django-socialregistration,出现以下错误:

Using django-socialregistration, got following error:

'AnonymousUser' object has no attribute 'backend'

如何


  1. I

  2. 那把我带到了Facebook并要求我登录。因此,在获得允许的情况下,我同意了。

  3. 之后,它会将我重定向到我的网站。并要求设置。我提供了用户和电子邮件地址。

  4. 提交后,出现如上错误:

  1. I click on facebook connect url.
  2. That took me Facebook and ask me to login. So I did, asked permission, I granted.
  3. After that it redirect me to my site. And ask to setup. I provide user and email address.
  4. Once I submit, got error like above:

跟踪点:

path/to_file/socialregistration/views.py in post
128.      self.login(request, user)

有人知道,怎么了?

推荐答案

哦,我一直都在遇到此错误,基本上您是在打电话

Oh man i used to get this error all the time, basically you are calling

self.login(request, user)

不调用

进行身份验证(用户名=用户,密码= pwd)

第一

当您调用 authenticate 时,django会在用户上设置backend属性,并指出要使用的后端,请参见此处以获取更多详细信息。 b $ b https://docs.djangoproject.com /en/dev/topics/auth/#django.contrib.auth.authenticate

when you call authenticate, django sets the backend attribute on the user, noting which backend to use, see here for more details https://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.authenticate

这篇关于'AnonymousUser'对象没有属性'backend'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆