Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#19573 closed Cleanup/optimization (fixed)

It is not possible to overwrite field label in AuthenticationForm

Reported by: jan.munclinger@… Owned by: slurms
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 Changed 2 years ago by claudep

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 2 years ago by sneawo

  • Owner changed from nobody to sneawo
  • Status changed from new to assigned

comment:3 Changed 2 years ago by slurms

  • Easy pickings unset
  • Has patch set
  • Owner changed from sneawo to slurms

comment:4 Changed 2 years ago by slurms

Added pull request, all tests pass on sqlite.

comment:5 Changed 2 years ago by slurms

comment:6 Changed 2 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In cdad0b28d49eecb13773c112410f3c126fdd1625:

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

comment:7 Changed 2 years ago by Claude Paroz <claude@…>

In b4544dbd5bf7fec73d03f31c0e59135d64fd818c:

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

Backport of cdad0b28d from master.

comment:8 Changed 2 years ago by Claude Paroz <claude@…>

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