Django 如何更改allauth中的电子邮件验证链接
我在django应用程序中使用allauth。一旦用户被创建,它就会发送一封带有如下链接的电子邮件Django 如何更改allauth中的电子邮件验证链接,django,angularjs,Django,Angularjs,我在django应用程序中使用allauth。一旦用户被创建,它就会发送一封带有如下链接的电子邮件http://localhost:8001/account/confirm-电子邮件/asdfafsd/ 但是,我希望链接是http://localhost:8001/verifyEmail/asdfafsd因为我在前端使用了angular 我不知道在哪里更改此链接?添加到URL.py自定义URL: url(r“^verifyEmail/(?p\w+)/$”,allauth.accounts.vie
http://localhost:8001/account/confirm-电子邮件/asdfafsd/
但是,我希望链接是http://localhost:8001/verifyEmail/asdfafsd
因为我在前端使用了angular
我不知道在哪里更改此链接?添加到URL.py自定义URL:
url(r“^verifyEmail/(?p\w+)/$”,allauth.accounts.views.confirm\u email,name=“my\u confirm\u email”)
并编辑电子邮件模板以使用“我的确认电子邮件”url:
templates/account/email\u confirmation\u message.txt
userprofile/templatetags/userprofile.py中的appuserprofile
userprofile.py中
代码可以是
from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()
@register.simple_tag(name="make_confirm_url", takes_context=True)
def make_confirm_url(context):
activate_url = context.get('activate_url')
slice_idx = activate_url.find('account')
return ''.join(['http://', context.get('current_site').domain, '/',activate_url[slice_idx:]])
{% load userprofile %}{% make_confirm_url as the_link %}
{% load account %}{% user_display user as user_display %}{% load i18n %}
{% autoescape off %}{% blocktrans with site_name=current_site.namesite_domain=current_site.domain %}
Hello from {{ site_name }}!
You're receiving this e-mail because user {{ user_display }} has given yours as an e-mail address to connect their account.
To confirm this is correct, go to {{the_link}}
{% endblocktrans %}{% endautoescape %}
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you from {{ site_name }} Dev Team !
{{ site_domain }}{% endblocktrans %}
email\u confirmation\u message.txt
可以是
from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()
@register.simple_tag(name="make_confirm_url", takes_context=True)
def make_confirm_url(context):
activate_url = context.get('activate_url')
slice_idx = activate_url.find('account')
return ''.join(['http://', context.get('current_site').domain, '/',activate_url[slice_idx:]])
{% load userprofile %}{% make_confirm_url as the_link %}
{% load account %}{% user_display user as user_display %}{% load i18n %}
{% autoescape off %}{% blocktrans with site_name=current_site.namesite_domain=current_site.domain %}
Hello from {{ site_name }}!
You're receiving this e-mail because user {{ user_display }} has given yours as an e-mail address to connect their account.
To confirm this is correct, go to {{the_link}}
{% endblocktrans %}{% endautoescape %}
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you from {{ site_name }} Dev Team !
{{ site_domain }}{% endblocktrans %}
如何编辑电子邮件模板?我在代码中的任何地方都找不到文件
account/email/email\u confirmation\u message.txt
。这似乎不是我想要的。verifyEmail
URL已经在我的angular应用程序中生成,并且工作得非常好。我只想将发送给用户的电子邮件中的URL更改为相同的verifyEmail
URL,而不是http://localhost:8001/account/confirm-email/asdfafsd/
这是我正在尝试更改的URL您说您想更改所有的电子邮件验证URL,但链接到github会导致django的用户密码重置电子邮件模板。您所需要做的就是在服务器端创建url。您只能通过angularjs在客户端完成。若要更改电子邮件中的url,您应该创建自定义电子邮件模板,该模板将覆盖来自allauth的标准模板。为此,您需要将模板目录从allauth复制到项目的模板目录,并编辑模板以进行电子邮件验证。