Opened 11 years ago

Closed 8 years ago

#20705 closed New feature (fixed)

Allow customizing the email field name for PasswordResetForm

Reported by: CHI Cheng Owned by: mlevental
Component: contrib.auth Version: dev
Severity: Normal Keywords:
Cc: CHI Cheng, jorgecarleitao, Aleksej Manaev, m.levental@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Like USERNAME_FIELD, add a similar parameter so PasswordResetForm, and other customized user model functions, do not rely on fixed name email field to send emails.

Attachments (1)

20705-initial.diff (1.9 KB ) - added by Tim Graham 9 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by CHI Cheng, 11 years ago

Cc: CHI Cheng added

comment:2 by Tim Graham, 11 years ago

Summary: Set email field for PasswordResetFormAllow customizing the email field name for PasswordResetForm
Triage Stage: UnreviewedAccepted

Seems like a reasonable request.

comment:3 by Susan Tan, 11 years ago

I've been reading this doc for context + background: https://docs.djangoproject.com/en/1.5/topics/auth/default/#django.contrib.auth.forms.PasswordResetForm

It seems that I'll need to edit the PasswordResetForm class method located in contrib.auth.forms. In particular, L27 might needed to be changed: "email = forms.EmailField(label=_("Email"), max_length=254)"

Is there an existing similar example that I can follow? I've done a global search on USERNAME_FIELD, which returned a lot of results; I'm not sure which are the relevant files to look at.

comment:4 by Tim Graham, 11 years ago

This isn't about renaming the form field, but rather not assuming the "email" field on the UserModel is called "email". We could accomplish this on PasswordResetForm by passing in a parameter to the save method with the name of the field, but it would be better to get an idea of the "other customized user model functions" the OP had in mind to better determine the feasibility and design of this.

comment:5 by jorgecarleitao, 10 years ago

Cc: jorgecarleitao added

Doesn't the ticket #17431 solves this?

comment:6 by Tim Graham, 9 years ago

No, I think it's still an issue. I'll attach a patch with a sketch of the code changes.

by Tim Graham, 9 years ago

Attachment: 20705-initial.diff added

comment:7 by Aleksej Manaev, 8 years ago

Cc: Aleksej Manaev added

comment:8 by mlevental, 8 years ago

Cc: m.levental@… added

comment:9 by mlevental, 8 years ago

Owner: changed from nobody to mlevental
Status: newassigned

comment:10 by Tim Graham, 8 years ago

Has patch: set
Patch needs improvement: set

I left some ideas for improvement on the PR.

comment:11 by mlevental, 8 years ago

Patch needs improvement: unset

comment:12 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 617e36dc:

Fixed #20705 -- Allowed using PasswordResetForm with user models with an email field not named 'email'.

Note: See TracTickets for help on using tickets.
Back to Top