[Answer]-Django-password-reset – how to set attributes

1👍

Just override Recover view like so:

class MyRecover(Recover):
    search_fields = ['email']

myrecover = MyRecover.as_view()

because there are two recover urls, you need to pass the one with signature first and then the overridden one and then the included one, seems not very DRY, but it’s the only way to make the urls be dispatched correctly:

url(r'^recover/(?P<signature>.+)/$', 'password_reset_recover.views.recover_done',
    name='password_reset_sent'),
# next we override our url, assuming your app name is called 'core'
url(r'^recover/$', 'core.views.myrecover', name='password_reset_recover'),
url(r'^/', include('password_reset.urls')),

0👍

The documentation for django-password-reset says that it uses django.contrib.auth.models.User (the django built in User model) to search for username or email. So here a username would exist.

If you want to change the functionality of the django-password-reset you can go into the forms.py file and change the form’s search_fields variable (and other logic) so that it only searches by email.

Here is the hyperlink to the forms.py:

https://github.com/brutasse/django-password-reset/blob/master/password_reset/forms.py

I’d start with changing the PasswordRecoveryForm

Leave a comment