Django 'AnonymousUser' object has no attribute '_meta'

前端 未结 6 1594
花落未央
花落未央 2020-12-11 14:48

I am using social login in my Django app. So, I have added additional backends in my settings.py file.

AUTHENTICATION_BACKENDS = [
    \'django.         


        
6条回答
  •  Happy的楠姐
    2020-12-11 15:10

    You already have the user when you save the form, so you don't need to call authenticate since you already provide the backend when calling login():

    user = form.save()
    login(request, user, backend='django.contrib.auth.backends.ModelBackend')
    

提交回复
热议问题