1

django-rest-auth을 사용하여 DRF에서 비밀번호 재설정 기능을 설정하려고했습니다. 나는 다음과 같은 코드django-rest-auth : 비밀번호 재설정 기능 관련 문제

serializer.py

from rest_auth.serializers import PasswordResetSerializer 
from allauth.account.forms import ResetPasswordForm 

class PasswordSerializer(PasswordResetSerializer): 
    password_reset_form_class = ResetPasswordForm 

settings.py

을 추가하여 해결 등록/password_reset_email.html : 이전 I 오류 TemplateDoesNotExist을 얻고 있었다
REST_AUTH_SERIALIZERS = { 
    'PASSWORD_RESET_SERIALIZER': 'api.serializers.PasswordSerializer', 
} 

그러나 이제 다른 문제가 있습니다 - "NoReverseMatch : 'account_reset_password_from_key'에 대한 Reverse가 없습니다. 'account_reset_password_from_key가' ". 유효한보기 기능이나 패턴 이름이 아닙니다. 그리고 이에 대한 모든 솔루션 또는 해결 방법을 발견하지 않았습니다.

어떤 도움을 주시면 감사하겠습니다.

+0

http://django-rest-auth.readthedocs.io/ko/latest/installation.html#installation의 3 단계에서 언급 한 URL을 추가 했습니까? 그렇다면 URL의 이름을 지정 했습니까? –

+0

예! 내가 언급 한 URL을 추가했다. 비밀 번호 재설정 흐름은 나에게 복잡해 보였다. 그러나 코드를 살펴보고 많은 디버깅을 한 후에 문제를 발견하고 현재 작동하고 있습니다. 그래도 제안에 감사드립니다! –

답변

2

그래서 결국 나는 암호를 가지고 작업 기능을 재설정 여기가는 방법입니다 -.

우리는 우리의 urls.py에 하나의 URL이 필요 -

urlpatterns = [ 
url(r'^account/', include('allauth.urls')), 
url(r'^rest-auth/', include('rest_auth.urls')), 

# This is the only URL required for BASIC password reset functionality. 
# This URL creates the confirmation link which is sent via e-mail. All of the rest 
# password reset features get their reverse lookup via django-allauth and django-rest-auth. 
url(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', TemplateView.as_view(), name='password_reset_confirm'), 

url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', allauthemailconfirmation, 
    name="account_confirm_email"), 
url(r'^rest-auth/registration/', include('rest_auth.registration.urls'), name='account_signup'), 
] 

이 URL 구성을 사용하면 TemplateDoesNotExist/api/rest-auth/password/reset/ 오류가 먼저 발생합니다. 많은 디버깅 후 템플릿에 문제가 발생했음을 발견했습니다. - registration/password_reset_email.html 이것은 Django Admin의 템플릿 디렉토리 아래에 있습니다. 이것은 내가 사용하고있는 다른 Django 응용 프로그램 때문에 발생했으며 장고 관리 응용 프로그램을 비활성화했습니다. INSTALLED_APPS에서 'django.contrib.admin'을 추가하고 시리얼을 제거

그래서이 문제를 해결.

다른 사람들에게도이 문제가 해결되기를 바랍니다.

PS : 디버거가 가장 친한 친구입니다. ;)