[英]How to replace localhost in emails with correct domain for django reset password?
我正在通過nginx為帶有反向代理的django應用程序提供服務。 該應用程序在本地localhost:8686下運行,該本地主機映射到example.com。 因此,重置密碼的正確鏈接類似於:
https://example.com:8686/accounts/reset/MQ/591-05377c39db92f2d5368a/
但這是電子郵件中顯示的內容:
https://localhost:8686/accounts/reset/MQ/591-05377c39db92f2d5368a/
顯然,django(本地與女服務員一起工作)不了解域名。 是否可以告訴django應該使用哪個域名?
做您想要的事情的第一種方法是通過創建自定義的registration/password_reset_email.html
覆蓋默認模板:
{# yourProject/yourApp/templates/registration/password_reset_email.html #}
{% trans "Please go to the following page and choose a new password:" %}
{% block reset_link %}
{{ protocol }}://domain.com{% url 'password_reset_confirm' uidb64=uid token=token %}
{% endblock %}
實現此目的的另一種方法是啟用“站點框架”(請參閱鏈接2)。
文件和來源:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.