6

I am using Django forgot_password framework with custom template. I am using Django 1.5. My custom template password_reset_email.html looks like this:

{% 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 %}

#Exception:
Exception Type: TemplateSyntaxError at /accounts/password/reset/
Exception Value: Could not parse the remainder: ',' from 'uid,'
pynovice
  • 7,424
  • 25
  • 69
  • 109

4 Answers4

16

Put this in the top:

 {% load i18n %}{% load url from future %}
 {% autoescape off %}
 ..........

Remove ,, you put it beside uidb36=uid,

 {% url 'django.contrib.auth.views.password_reset_confirm' uidb36=uid token=token %}
catherine
  • 22,492
  • 12
  • 61
  • 85
  • One more question before I accept the answer, I want password reset URL with my URL. Should I type it manually or ? Right now, instead of example.com I want it to go to 127.0.0.1:8000. – pynovice Mar 27 '13 at 08:41
  • No the protocol and domain right here {{ protocol }}://{{ domain }}, are they stored in a database? – pynovice Mar 27 '13 at 08:45
  • don't change the protocol, it's automatic, it's either http or https or whatever – catherine Mar 27 '13 at 08:47
11

I don't have enough reputation points to comment on the accepted answer, but the {% load url from future %} shouldn't be required since you're using Django 1.5. It was only needed in Django 1.3 and 1.4. https://docs.djangoproject.com/en/dev/releases/1.3/#changes-to-url-and-ssi

Derek
  • 520
  • 1
  • 5
  • 19
  • So the real problem in the template is the lack of quotes around the view, and the additional ',' character after uid? – winwaed Apr 08 '14 at 17:59
  • Just a note to confirm Derek's answer and winwaed's comment. Fixing the quotes and removing the comment was the answer for me. +1 – Guerry May 11 '16 at 03:23
1

As of 2022 (django version 4.0.5), none of the answers here worked for me. I had to change the line:

{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %}

to:

{% url 'password_reset_confirm' uid token %}

where password_reset_confirm is the name that I have given to the password reset confirm view in my url pattern, which is located in the urls.py file insde the app where I am managing my user registration system (the app is called users):

path('pattern/<uidb64>/<token>', django.contrib.auth.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'), name='password_reset_confirm')
Clerni
  • 252
  • 7
  • 18
0

my issue is resolved by writing this I'm using django 4.1

{% url 'password_reset_confirm' uidb64=uid token=token %}

  • Does this answer the implied *How do I get rid of Django Template Error: Could not parse the remainder: ',' from 'uid,'*? (What *has* been your issue?) – greybeard Mar 10 '23 at 22:11