0

所以我使用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')),
4

2 回答 2

4

在这里找到这个

要自定义发送出去的电子邮件,请复制这些文件(在您的 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-04-15T16:44:45.297 回答
0

(如果我明白你在问什么)

在您的 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

于 2017-03-22T18:22:09.010 回答