【问题标题】:cookiecutter django edit emailcookiecutter django 编辑电子邮件
【发布时间】:2017-03-16 00:43:09
【问题描述】:

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

【问题讨论】:

    标签: python django cookiecutter-django


    【解决方案1】:

    找到这个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
    

    并对本地副本进行任何您喜欢的更改。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-03-14
        • 1970-01-01
        • 1970-01-01
        • 2014-06-14
        • 2018-03-26
        • 1970-01-01
        • 2017-09-17
        • 2018-03-25
        相关资源
        最近更新 更多