Opened 5 years ago

Closed 7 weeks ago

Last modified 7 weeks ago

#13015 closed Bug (fixed)

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

Reported by: Wedg Owned by: timgraham
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes 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.

Change History (11)

comment:1 in reply to: ↑ description Changed 5 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 5 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 4 years ago by lukeplant

  • Type set to Bug

comment:4 Changed 4 years ago by lukeplant

  • Severity set to Normal

comment:5 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:6 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:7 Changed 7 weeks ago by timgraham

  • Has patch set
  • Owner changed from nobody to timgraham
  • Status changed from new to assigned

comment:8 Changed 7 weeks ago by claudep

  • Triage Stage changed from Accepted to Ready for checkin

comment:9 Changed 7 weeks ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In a40a34a4b2d79dbf798df538c26222148d42b17c:

Fixed #13015 -- Clarified language about model instances attached to forms.

comment:10 Changed 7 weeks ago by Tim Graham <timograham@…>

In cc525e31bba1951a81eae3d2bf8625eeb14eb0a1:

[1.8.x] Fixed #13015 -- Clarified language about model instances attached to forms.

Backport of a40a34a4b2d79dbf798df538c26222148d42b17c from master

comment:11 Changed 7 weeks ago by Tim Graham <timograham@…>

In 5ebe921a8e4ea947580467b904105e14cbef3071:

[1.7.x] Fixed #13015 -- Clarified language about model instances attached to forms.

Backport of a40a34a4b2d79dbf798df538c26222148d42b17c from master

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