Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#19573 closed Cleanup/optimization (fixed)

It is not possible to overwrite field label in AuthenticationForm

Reported by: jan.munclinger@… Owned by: Nick Sandford
Component: contrib.auth Version: 1.5-beta-1
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If I inherit "django.contrib.auth.forms.AuthenticationForm" and specify my custom "username" field

username = forms.CharField(label=_("Name"), max_length=75)

it ignores my label.

The reason is the last line of the init method, which set the label.
https://github.com/django/django/commit/70a0de37d132e5f1514fb939875f69649f103124#L10R164

There could be an if statement:

if not self.fields['username'].label:
    self.fields['username'].label = capfirst(self.username_field.verbose_name)

Change History (8)

comment:1 by Claude Paroz, 11 years ago

Easy pickings: set
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:2 by sneawo, 11 years ago

Owner: changed from nobody to sneawo
Status: newassigned

comment:3 by Nick Sandford, 11 years ago

Easy pickings: unset
Has patch: set
Owner: changed from sneawo to Nick Sandford

comment:4 by Nick Sandford, 11 years ago

Added pull request, all tests pass on sqlite.

comment:5 by Nick Sandford, 11 years ago

comment:6 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In cdad0b28d49eecb13773c112410f3c126fdd1625:

Fixed #19573 -- Allow override of username field label in AuthenticationForm

comment:7 by Claude Paroz <claude@…>, 11 years ago

In b4544dbd5bf7fec73d03f31c0e59135d64fd818c:

[1.5.x] Fixed #19573 -- Allow override of username field label in AuthenticationForm

Backport of cdad0b28d from master.

comment:8 by Claude Paroz <claude@…>, 11 years ago

In b4544dbd5bf7fec73d03f31c0e59135d64fd818c:

[1.5.x] Fixed #19573 -- Allow override of username field label in AuthenticationForm

Backport of cdad0b28d from master.

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