Django 'AnonymousUser' object has no attribute '_meta'

前端 未结 6 1589
花落未央
花落未央 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条回答
  •  粉色の甜心
    2020-12-11 15:13

    Cause of Returning None While logging with created user from registration form , in DB it is checking specific user with encrypted password ,but we are saving password in text from that is why if you give even correct username and password ,it is failing

    Add below model backends in setting.py file

    AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.ModelBackend',)

    or pass backend to login function itself

    login(request, username,password, backend='django.contrib.auth.backends.ModelBackend')

    import make_password function and pass password to it which is comming from registration form then it will save password into Db in encrypted form

    from django.contrib.auth.hashers import make_password

    raw_pass = form.cleaned_data.get('password') raw_pass = make_password(form.cleaned_data.get('password'))

    Django=2.2.4

提交回复
热议问题