Django

Code

Ticket #9746 (closed: invalid)

Opened 1 year ago

Last modified 1 year ago

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

Reported by: waltercruz Assigned to: nobody
Milestone: Component: Forms
Version: 1.0 Keywords: forms, model, verbose name, label
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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?

Attachments

Change History

12/03/08 07:48:52 changed by waltercruz

  • keywords set to forms, model, verbose name, label.
  • needs_better_patch changed.
  • component changed from Uncategorized to Forms.
  • needs_tests changed.
  • needs_docs changed.

12/03/08 10:40:57 changed by brosner

  • status changed from new to closed.
  • resolution set to invalid.

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.


Add/Change #9746 (Using a custom widget for a item in ModelForm should use the model verbose_name?)




Change Properties
Action