-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change lookup value to dynamic value #93
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Universal approach to a user-defined lookup-field makes a lot of sense. I only ask you to explicate that it's not limited to email in the docs (Just insert a generic term instead of "custom_email_field", see the comment below)
Please also pull the recent changes from master and resolve the conflict in django_rest_passwordreset/views.py.
## Custom Email Lookup | ||
|
||
By default, `email` lookup is used to find the user instance. You can change that by adding | ||
By default, `email` lookup is used to find the user instance. You can change that by adding | ||
```python | ||
DJANGO_REST_LOOKUP_FIELD = 'custom_email_field' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The heading is no longer correct when the lookup-field can be anything, not only email.
'custom_email_field' should be changed to a more generic value too, to make clear that the lookup-field is not limited to an email-adress
Problem
This package is limited to recovering passwords by email
Solution
Make the lookup field dynamic so it can be used for any field.
Example
You want to recover a user by
username
,You set up the settings to
DJANGO_REST_LOOKUP_FIELD= 'username'
.When calling the API, the request body should be
As a result, on the
ResetPasswordRequestToken
view the query will beusername__iexact="mycoolusername"
.