Opened 11 years ago

Closed 11 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

Description

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

username = forms.CharField(label='')

...it 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/forms.py 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 by Baptiste Mispelon, 11 years ago

Resolution: duplicate
Status: newclosed

Hi,

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

Thanks.

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