2013-02-20 2 views
0

암호 재설정을 위해 내장 된 auth.views 및 auth.form을 사용하려고합니다.Django : Builtin Views 및 Forms throwing "객체에 속성이 없습니다. users_cache '"

class CustomPasswordResetForm(PasswordResetForm): 
    def clean_email(self): 
     email = self.cleaned_data.get('email') 
    if email and 'gmail.com' in email: 
     raise forms.ValidationError(u'Unfortunately, we can not reset Gmail usernames') 
    return email 

그리고 urls.py에 다음과 같은 :

forms.py에서 다음을 가지고 내가 [email protected] 같은 이메일을 입력하면

url(r'^passreset/$', auth_views.password_reset, {'template_name': 'registration/password_reset.html', 'password_reset_form': CustomPasswordResetForm}), 

, 그것은 제대로 유효성 검사 오류가 발생합니다. 내가 Gmail이 아닌 이메일을 입력 할 경우, 그것의 여부를 슈퍼 클래스의 적절한 이메일 주소의 유효성을 검사하지만, 이메일과 연관된 사용자가이 있는지 여부를 확인하지 않고 대신 반환

AttributeError at /passreset/ 
'CustomPasswordResetForm' object has no attribute 'users_cache' 

어떤 아이디어? 나는 어디서부터 시작해야할지 모르겠다. 구글 검색은별로 도움이되지 못했다.

답변

0

문제가 해결되었습니다. clean_email을 재정 의하여 일단 수퍼 클래스에서 원래 메서드를 호출하는 것을 잊어 버렸습니다. 세 번째 줄을 아래로 변경하면 문제가 해결됩니다.

email = super(CustomPasswordResetForm, self).clean_email() 
관련 문제