Django rest framework: Obtain auth token using email instead username

前端 未结 4 1766
有刺的猬
有刺的猬 2020-12-24 08:39

I\'m working on a project to enable the django rest framework authentication for mobile devices. I\'m using the default token authentication for get the user token from a po

4条回答
  •  没有蜡笔的小新
    2020-12-24 09:25

    Write these requirements into your settings.py

    ACCOUNT_AUTHENTICATION_METHOD = 'email'
    ACCOUNT_EMAIL_REQUIRED = True
    ACCOUNT_USERNAME_REQUIRED = False
    

    To check, send this json format request to your server:

    {
        "username":"youremail@mail.domain",
        "password":"Pa$$w0rd"
    }
    

提交回复
热议问题