所以我使用的是cookiecutter-django,它有用于用户注册的django-allauth和用于发送电子邮件的后端django-anymail。我想要自定义用户注册或忘记密码时发送给他们的电子邮件。我似乎找不到我的cookiecutter-django项目中的代码,它似乎是从我的应用程序外部的模板(可能在任何邮件模块中)完成的,所以我不知道我应该在哪里或者如何编写自定义的电子邮件消息。此外,由于注册模板在我的项目中没有视图,因此我无法通过调试器找到我的方法。这是调用注册模板的url代码:
<li class="nav-item mx-md-3">
<a id="sign-up-link" class="nav-link" href="{% url 'account_signup' %}"><i class="fa fa-user-plus"></i> {% trans "Sign Up" %}</a>
</li>这是我的项目中的URL配置:
# User management
url(r'^users/', include('solucionesverdesweb.users.urls', namespace='users')),
url(r'^accounts/', include('allauth.urls')),发布于 2017-04-16 00:44:45
找到此here
要自定义发出的电子邮件,请复制以下文件(在python站点包目录中):
site-packages/allauth/templates/account/email/email_confirmation_message.txt
site-packages/allauth/templates/account/email/email_confirmation_subject.txt添加到应用程序的模板目录:
your-app/templates/account/email/email_confirmation_message.txt
your-app/templates/account/email/email_confirmation_subject.txt并对本地副本进行任何您喜欢的更改。
发布于 2017-03-23 02:22:09
(如果我明白你在问什么)
在你的urls.py中,你可以使用类似这样的东西:https://docs.djangoproject.com/en/1.10/topics/auth/default/#module-django.contrib.auth.views
url(r'^password_reset/$',
auth_views.password_reset,
{'current_app': 'accounts',
'template_name': 'accounts/password_reset.html',
'email_template_name': 'accounts/password_reset_email.html',
'password_reset_form': MyPasswordResetForm,
'post_reset_redirect': '/accounts/password_reset_done/', },
name='password_reset'),您可以检查Django代码上的所有可用选项:https://github.com/django/django/blob/master/django/contrib/auth/views.py#L214
https://stackoverflow.com/questions/42823335
复制相似问题