Django Template Error: Could not parse the remainder: ',' from 'uid,'?
Asked Answered
C

4

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,'
Charmion answered 27/3, 2013 at 8:28 Comment(0)
I
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 %}
Intercalate answered 27/3, 2013 at 8:32 Comment(3)
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.Charmion
No the protocol and domain right here {{ protocol }}://{{ domain }}, are they stored in a database?Charmion
don't change the protocol, it's automatic, it's either http or https or whateverIntercalate
T
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

Trough answered 4/4, 2013 at 21:45 Comment(2)
So the real problem in the template is the lack of quotes around the view, and the additional ',' character after uid?Vulcanize
Just a note to confirm Derek's answer and winwaed's comment. Fixing the quotes and removing the comment was the answer for me. +1Awl
J
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')
Jeopardize answered 9/6, 2022 at 16:17 Comment(0)
R
0

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

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

Redbud answered 5/3, 2023 at 10:43 Comment(1)
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?)Rebak

© 2022 - 2024 — McMap. All rights reserved.