Opened 5 years ago

Closed 5 years ago

#20617 closed Uncategorized (duplicate)

AuthenticationForm ignores setting "username" field's label to an empty string

Reported by: xor-xor Owned by: nobody
Component: contrib.auth Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When I inherit "django.contrib.auth.forms.AuthenticationForm" and set the "username" field's label to an empty string:

username = forms.CharField(label='') is ignored and the "Username:" label is rendered in HTML output.

Trying the same thing with "password" field works as expected (i.e. label is not rendered), so this behaviour is inconsistent.

I think it is related to the following if statement in django/contrib/auth/ file:

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

(see also: ticket #19573)

Change History (1)

comment:1 Changed 5 years ago by Baptiste Mispelon

Resolution: duplicate
Status: newclosed


This issue has already been reported in ticket #20357 and a fix was commited with commit 0732c8e8c6e156d4d9a4a1cc02d631fe41342bf8.


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