One thing I’ve learned from debugging code is that its not always a single problem, sometimes you have multiple things gone wrong. I had two issues that I think caused similar behavior to the original poster’s.
First there was the left and right apostrophe characters that made the password link look like this:
http://localhost:8000{% url ΓÇÿdjango.contrib.auth.views.password_reset_confirmΓÇÖ uidb64=uid token=token %}
As suggested before by the author, I believe that was the book’s formatting. Replacing those 4 ‘smart apostrophe’ characters in password_reset_email.html with plain single quote characters got rid of the broken character encoding, but I still did not get a usable reset link. It showed up like this, on three separate lines:
http://localhost:8000{% url
'django.contrib.auth.views.password_reset_confirm' uidb64=uid
token=token %}
That was my clue! The stuff inside of {% and %} is supposed to go to the Python interpreter to run as code. So what I think was happening was that my editor broke up the {% url ‘django …’ %}
part and messed up the Python function call that was supposed to generate the random text for the reset link.
Anyway, putting everything from {{ protocol }}
through token=token %}
on a single line in my text editor finally gave me this:
http://localhost:8000/accounts/password/reset/confirm/NQ/43a-fda06baa91ccfff3484e/
Its really annoying, because indentation matters in Python and various text tools (like Adobe Acrobat) seems to get it wrong frequently. I had a hard time getting exactly what I was seeing into this post without the editor changing things. I hope this helps!
Bob M