'AnonymousUser' object has no attribute 'backend'

前端 未结 3 1375
夕颜
夕颜 2021-01-05 17:39

Using django-socialregistration, got following error:

\'AnonymousUser\' object has no attribute \'backend\'

How,

  1. I click on f
3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-05 18:14

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

    self.login(request, user)
    

    without calling

    authenticate(username=user, password=pwd)

    first

    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

提交回复
热议问题