【问题标题】:Why isn't the Django out-of-the-box password-reset feature working?为什么 Django 开箱即用的密码重置功能不起作用?
【发布时间】:2014-02-14 23:06:02
【问题描述】:

我正在使用 Django 1.6。 我在 myApp/templates/registration/password_reset_email.html 中有以下文件。

但是,当我在表单中输入我的电子邮件地址以发送重置密码电子邮件时,我收到以下错误:

TemplateSyntaxError at /auth/password_reset/
Could not parse the remainder: ',' from 'uid,'

下面的模板有什么问题导致 {% url %} 标签失败?

{% autoescape off %}
You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.

Please go to the following page and choose a new password:
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %}
{% endblock %}

Your username, in case you've forgotten: {{ user.username }}

Thanks for using our site!

The {{ site_name }} team.

{% endautoescape %}

【问题讨论】:

    标签: django


    【解决方案1】:

    当您使用带有多个参数的模板标签时,请用空格分隔它们。

    点赞{{ protocol }}://{{ domain }}{% url 'django.contrib.auth.views.password_reset_confirm' uidb36=uid token=token %}(注意“uid”后面没有,。

    我认为这就是解决方案。 有关自定义模板标签及其工作方式的更多信息,请参阅 https://docs.djangoproject.com/en/dev/howto/custom-template-tags/

    【讨论】:

    • 如何使这封电子邮件的外观和感觉与我的应用程序中的其他 HTML 电子邮件一样?我有一个名为 baseEmail.html 的模板,其中包含漂亮的页眉和页脚。但是当我让这个文件扩展 baseEmail.html 时,我会在电子邮件的文本中看到所有的 HTML 代码。
    猜你喜欢
    • 2021-03-24
    • 2021-04-09
    • 1970-01-01
    • 2013-05-17
    • 1970-01-01
    • 1970-01-01
    • 2019-12-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多