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

标签 python django django-registration

我遇到了 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/

相关文章:

python - 如何在python中上传文件时读取内存中zip文件的内容?

python - django-registration 和包含 hashtag 的重定向

python - 如何在本地计算机(Mac 10.7)上测试发送带有 Django 注册的电子邮件?

django - 是否可以从 Django 请求检测浏览器刷新?

python - 扩展 django-inspectional-registration 中的 View

python - 'tensorflow' 没有属性 'to_int32'

python - 如何在没有错误的情况下访问 iFrame 内的不和谐小部件?

python - NoneType'对象没有属性 '_inbound_nodes'

javascript - 使用 ajax 调用 Flask 服务器进行登录身份验证(管道损坏)

django - 如何阻止所有非美国 IP 地址访问我的网站?