2017-01-28 3 views
0

비밀번호를 재설정하기 위해 내장 된 auth.views를 사용하도록 장고 애플리케이션을 설정했습니다. 문제는 메시지가 다음과 같이 표시된다는 것입니다.Django는 비밀번호 재설정 이메일 제목을 지정합니다.

Subject: Password reset on 127.0.0.1:8001 

You're receiving this email because you requested a password reset for your user account at 127.0.0.1:8001. 

Please go to the following page and choose a new password: 

http://127.0.0.1:8001/accounts/reset/MQ/4j3-d83f7cdb7f0203afe85e/ 

Your username, in case you've forgotten: myuser 

Thanks for using our site! 

The 127.0.0.1:8001 team 

gunicorn 배포에서 localhost를 가져 오는 것 같습니다. 나는 nginx가 도메인 @port 80을 포트 8001에서 localhost로 라우팅하도록 설정했다. 어떻게 이것을 변경하여 "http://mydomain/accounts/reset ...."이 될까?

충분히 구체적인 것은 아니기 때문에 사람이 downvoting하는 것처럼 보입니다. 여기에 내가 설정 한 내용은 다음과 같습니다

url(r'^resetpassword/passwordsent/$', password_reset_done, {'template_name': 'password_recovery/recover_password_sent.html'}, name='password_reset_done'), 
url(r'^resetpassword/$', password_reset, {'template_name': 'password_recovery/recover_password.html'}, name='password_reset'), 

이러한 URL은 django.contrib.auth.views에서 당기는. 그리고 {{domain}} 변수가 이메일을 만드는 데 사용하고있는 것 같습니다. 문제는 gunicorn 데몬이 localhost의 포트 8001에 바인드하고 있기 때문에 localhost를 내 도메인으로 사용하고 있다는 것입니다. 실제 도메인을 얻을 수 있도록 수정하는 방법은 무엇입니까? settings.py에는 변수가 있습니까?

답변

1

Site 개체에서 사이트 이름이 표시되는 것처럼 보이거나 사용할 수없는 경우 request.META에서 나타납니다.

https://docs.djangoproject.com/en/1.10/topics/auth/default/#django.contrib.auth.views.password_reset

그래서 사이트의 목적은 당신을 위해이 문제를 해결할 수있는 구성.

+0

비밀번호 재설정보기를 연장해야한다는 의미입니까? –

+0

아니요, 관리자 또는 셸을 사용하여 Site 개체를 추가하고 사용하려는 이름을 지정하십시오. 아마도 관련성이 있습니다 : https://docs.djangoproject.com/en/1.10/ref/contrib/sites/ – user6731765

+0

그래, 그 트릭을 한 것처럼 보입니다! 정말 고맙습니다. 이것이 존재한다는 것을 몰랐습니다! –

1

난 그냥 리셋 템플릿의 도메인 변수가 거기에서 촬영되기 때문에, 관리자 및 http://mydomain로 사이트를 구성로 이동 한 생각 : 템플릿

current_site = get_current_site(request) 
    site_name = current_site.name 
    domain = current_site.domain 

:

보기

{% autoescape off %}{% load usertools %}Hi {{user|display_name}}, 

You're receiving this email because you requested a password reset for your user account at {{domain}}. 

Your username: {{user.get_username}} 

Please go to the following page and choose a new password: 

{{protocol}}://{{domain}}{% url 'password_reset_confirm' uidb64=uid token=token %} 

If clicking isn't working for you, simply paste the URL into your favorite web browser. 

See you soon!{% endautoescape %} 
+0

현재 buil 주석보기를 사용하고 있습니다. 이것은 내가 그 견해를 다시 만들어야한다는 것을 의미합니까? –

관련 문제