#19573 closed Cleanup/optimization (fixed)
It is not possible to overwrite field label in AuthenticationForm
| Reported by: | 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 , 13 years ago
| Easy pickings: | set |
|---|---|
| Severity: | Normal → Release blocker |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:3 by , 13 years ago
| Easy pickings: | unset |
|---|---|
| Has patch: | set |
| Owner: | changed from to |
comment:4 by , 13 years ago
comment:6 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
Added pull request, all tests pass on sqlite.