gpt4 book ai didi

python - Django-注册。发送的激活链接缺少我的应用名称

转载 作者:太空宇宙 更新时间:2023-11-03 15:21:56 26 4
gpt4 key购买 nike

我遇到了 django-registration 模块的问题。当用户尝试注册时,他在电子邮件中收到的激活链接不正确。我的意思是,要使链接正常工作,我必须在域名后面手动添加我的应用名称。

让我用一个例子来解释一下:

这是主页面 url(注意“HELLOPROJECT”):http://127.0.0.1:8000/HELLOPROJECT/index

这是注册网址(注意“HELLOPROJECT”):http://127.0.0.1:8000/HELLOPROJECT/accounts/register/

这是电子邮件中发送的激活 url(注意没有“HELLOPROJECT”): http://127.0.0.1:8000/accounts/activate/3a97ec229308b0112cb6e1ef16f8ab32df667b9c/

如果我点击上面的链接,就会发生错误。我必须手动添加“HELLOPROJECT”才能使链接正常工作并注册用户。

那么,为什么会这样呢?我该如何解决?

最佳答案

激活邮件模板包括

{{site}}/accounts/activate/{{ activation_key }}/

首先确保您的注册模板副本正确无误。然后确保 settings.py 中的 SITE_ID 与您创建的 site 匹配。 djangoproject.com 站点可能是默认站点并且具有 id 1。如果您编辑它的名称以匹配您的站点,id 将保持不变,如果您添加一个新的找到新的 id 并设置您的 SITE_ID

网站

An object representing the site on which the user registered; depending on whether django.contrib.sites is installed, this may be an instance of either django.contrib.sites.models.Site (if the sites application is installed) or django.contrib.sites.models.RequestSite (if not). Consult the documentation for the Django sites framework for details regarding these objects' interface

关于python - Django-注册。发送的激活链接缺少我的应用名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13570584/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com