即使注册成功,Django rest_auth.registration 也会发回错误

ohi*_*hid 5 python authentication django rest vue.js

我正在制作一个使用 Vuejs 作为前端的网站。对于注册,我使用rest_auth.registration。

在 Vuejs 代码中,我通过 axios 发出注册 post 请求。

  axios.post(this.registrationUrl,{
    username,
    email,
    password1,
    password2,
  }).then(res => {
    console.log('Registration Successful!')
  }).catch(err => {
    // console.log('There is error!')
    let errData = err.response.data
    this.errors.push(errData)
     for (let errorType in errData) {
      for (let error of errData[errorType]) {
        this.errors.push(error)
      }
    } 
  })  
Run Code Online (Sandbox Code Playgroud)

问题是,在注册用户时,即使注册成功并且可以在 django 管理面板中看到新用户,代码中的 Promise 也会返回错误。

返回错误:

OSError at /rest-auth/registration/ [Errno 99] Cannot assign requested address Request Method: POST Request URL: http://localhost:8000/rest-auth/registration/ Django Version: 1.11.8 
Run Code Online (Sandbox Code Playgroud)

Mar*_*ind 3

我能够通过在 Django 设置中设置EMAIL_BACKENDEMAIL_FILE_PATH(如果适用,取决于您选择的后端)来解决此问题。

当它尝试发送注册确认电子邮件时,似乎发生了错误。

所以就我的本地开发而言:

EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = os.path.join(BASE_DIR, 'tmp/email')
Run Code Online (Sandbox Code Playgroud)