AuthenticationForm ignores setting "username" field's label to an empty string
|Reported by:||xor-xor||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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)