Opened 15 years ago

Closed 15 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: no UI/UX: no

Description

Hi all! To simplify my question, I will use a sample code from the docs: http://docs.djangoproject.com/en/dev/topics/forms/modelforms/?from=olddocs#a-full-example.

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 by Walter Rodrigo de Sá Cruz, 15 years ago

Component: UncategorizedForms
Keywords: forms model verbose name label added

comment:2 by Brian Rosner, 15 years ago

Resolution: invalid
Status: newclosed

This is documented behavior. http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-field-types. 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