cookiecutter Django编辑emai

2024-05-15 15:11:57 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我使用cookiecutter-django,其中django-allauth用于用户注册,django-anymail作为发送电子邮件的后端。 我想定制发送给用户的电子邮件,当他们注册或忘记他们的密码。我似乎找不到我的cookiecutter django项目中的代码,它似乎是从我的应用程序外的模板(可能在anymail模块中)完成的,所以我不知道我应该在哪里或如何编写定制的电子邮件消息。另外,由于注册模板在我的项目中没有视图,我无法通过调试器找到方法。这是调用注册模板的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配置:

^{pr2}$

Tags: 项目django代码模板url电子邮件linkli
2条回答

(如果我理解你的要求)

在你的网址.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

找到这个here

要自定义发送的电子邮件,请复制以下文件(在python site packages目录中):

site-packages/allauth/templates/account/email/email_confirmation_message.txt
site-packages/allauth/templates/account/email/email_confirmation_subject.txt

到应用程序的模板目录:

^{pr2}$

并对本地副本进行任何更改。在

相关问题 更多 >