How to use a different domain for Djoser email?

☆樱花仙子☆ 提交于 2021-02-11 13:47:40

问题


How can I change the domain the link inside the email djoser sends uses?


回答1:


I figured this out, to change the link domain you need to add DOMAIN and SITE_NAME to your project settings. Example:

DOMAIN = config('DOMAIN') #example.com
SITE_NAME = config('SITE_NAME') #Example

 DJOSER = {
    'LOGIN_FIELD':'email',
    'USER_CREATE_PASSWORD_RETYPE':True,
    'ACTIVATION_URL': '/users/activate/{uid}/{token}',
    'SEND_ACTIVATION_EMAIL': True,
    'SERIALIZERS':{
        'user_create':'userauth.serializers.UserCreateSerializer',
        'user':'userauth.serializers.UserCreateSerializer',
        'activation': 'djoser.email.ActivationEmail',
}

Then you should get the next link in your email:

http://example.com/auth/users/activate/MQ/5c9-26bcab9e85e8a967731d


来源:https://stackoverflow.com/questions/62586797/how-to-use-a-different-domain-for-djoser-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!