Opened 9 years ago

Closed 9 years ago

#9746 closed (invalid)

Using a custom widget for a item in ModelForm should use the model verbose_name?

Reported by: Walter Rodrigo de Sá Cruz Owned by: nobody
Component: Forms Version: 1.0
Severity: Keywords: forms, model, verbose name, label
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Hi all! To simplify my question, I will use a sample code from the docs:

Say, by example, that I have added verbose names to the three fields, name as "Full Name", title as "Honor Title" and birth_date as "Birthday". Using a custom widget on a model form (like the sample, widget=forms.Select(choices=TITLE_CHOICES) to the title field) will make my form don't use the verbose name from the modelas the label. To add the correct label, I've to add a label='Something'. I expected that the generated model would use the verbose names from the model, even if I override some widget. Am I right in my expectation?

Change History (2)

comment:1 Changed 9 years ago by Walter Rodrigo de Sá Cruz

Component: UncategorizedForms
Keywords: forms model verbose name label added

comment:2 Changed 9 years ago by Brian Rosner

Resolution: invalid
Status: newclosed

This is documented behavior. You either just have to re-specify it or override the ModelForm's __init__ and pop the widget it through self.fields.

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