NOTE before reading this - I had to update the ‘@’ symbols with ‘AT’ because the site won’t let me ‘mention’ more than 2 users… just assume where I have AT that it is an @
Going through the "Adding A Registration Page’ chapter and have everything almost working but…
For some reason the reset link that I get directs me to example.com instead of localhost. I can’t figure out why, its not adding up for me. I tried a number of things and the only relation to example.com that I can see is the ‘fake’ email address that I’m trying to reset is 123testATexample.com. Here is the .txt file - exactly as what is in the book:
{% autoescape off %}
You’re receiving this email because you requested a password reset.
Please go to the following page and choose a new password:
{% block reset_link %}{{ protocol }}://localhost:8000{% url
’django.contrib.auth.views.password_reset_confirm’ uidb64=uid token=token %}
{% endblock %}
Your username, in case you’ve forgotten: {{ user.username }}
{% endautoescape %}
And here is the email I receive:
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Password reset on example.com
From: testingATexample.com
To: 123testATexample.com
Date: Sat, 09 Sep 2017 20:58:51 -0000
Message-ID: <20170909205851.6986.2651ATtotum>
You’re receiving this email because you requested a password reset for your user account at example.com.
Please go to the following page and choose a new password:
http://example.com/accounts/password/reset/Nw/4pb-a017b169f91765cbbe5d/
Your username, in case you’ve forgotten: 123test
Thanks for using our site!
The example.com team
You can see it says its coming from the “example.com team” and link contains http://example.com/,,,,, and not http://localhost:8000… which I would expect. The link works if I replace the ‘example.com’ portion with ‘localhost:8000’ and I’m able to complete the reset process. But why is it giving me an example.com web address at all??? It has me kind of baffeld…
Here’s my settings.py :
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend’
DEFAULT_FROM_EMAIL = 'testingATexample.com’
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
LOGIN_REDIRECT_URL = "home"
EMAIL_PORT = 1025
***Notes - I’ve tried a number of things like setting an additional line to EMAIL_HOST = ‘127.0.0.1:8000’ and ‘localhost:8000’ (and without the ‘8000’ piece. Seemed to have no effect either way with or without.
Also changed my DEFAULT_FROM_EMAIL to ‘testingATlocalhost.com’ (just to get rid of the reference of example.com) had no affect.
Cleared cache
A couple of other things…
I’m not too to concerned with it because I can simply edit the link and stick in ‘localhost:8000’ where example.com is and continue…but would like to know what is happening so when I come back to this for my own page I won’t run into again.