Code

Opened 4 years ago

Last modified 4 years ago

#13015 new Bug

Language regarding ModelForms with instances attached vs. bound Forms is unclear

Reported by: Wedg Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I discovered that providing initial via the field = FormField(initial='foobar') method and form = ModelForm(initial={'field':'method'}) behaves differently when the ModelForm is attached to a difference.

The documentation refers to a model instance bound to a form (at least in one location: http://docs.djangoproject.com/en/1.1/topics/forms/modelforms/#overriding-the-clean-method).

And also the documentation describing initial (both for fields and Forms) says that it only provides a value for unbound forms.

Perhaps we could clarify the language to say that an instance is attached to a ModelForm, but the form itself is unbound - and maybe yet further explain that any initial= values for a FormField will be overridden by the values from an attached model instance, which in turn will be overridden by any initial= values provided to the ModelForm at runtime.

Attachments (0)

Change History (6)

comment:1 in reply to: ↑ description Changed 4 years ago by Wedg

Replying to Wedg:

I discovered that providing initial via the field = FormField(initial='foobar') method and form = ModelForm(initial={'field':'method'}) behaves differently when the ModelForm is attached to a difference.

This should read "attached to an instance." This is what no sleep gets you. I apologize.

comment:2 Changed 4 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Accepted

Yes, the model form documentation's use of an instance being "bound" to a form is confusing at best.

comment:3 Changed 3 years ago by lukeplant

  • Type set to Bug

comment:4 Changed 3 years ago by lukeplant

  • Severity set to Normal

comment:5 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:6 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.