Opened 10 years ago

Closed 9 years ago

#23955 closed Bug (fixed)

Documentation mentions {{ form.id }} for formsets

Reported by: Marek Onuszko Owned by: you-n-g
Component: Documentation Version: dev
Severity: Normal Keywords: formset id form
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Documentation from 1.4 up to dev mentions a mysterious variable {{ form.id }} for formsets. However, no such thing seems to exist, and it prints an empty string instead. The closest equivalent seems to be {{ form.prefix }}.

https://docs.djangoproject.com/en/1.5/topics/forms/formsets/#manually-rendered-can-delete-and-can-order

I stumbled upon this while working on a contact form, and apparently it does seem to print something if the formset is based on a ModelForm. But in such case it's still unclear what {{ form.id }} is supposed to mean. What id is that ?

Change History (8)

comment:1 by Baptiste Mispelon, 10 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

Hi,

I don't get what {{ form.id }} is supposed to be either. It was mentionned in the original ticket (#16126) and I'm guessing it was specific to that use-case (the form probably had a field called id).

I think we can safely remove that line.

However, reading that code example I noticed that it's missing the {{ form.published_date }} field so it'd be nice to add it while we're changing that code.

Thanks!

comment:2 by Berker Peksag, 10 years ago

Has patch: set
Version: 1.7master

comment:3 by you-n-g, 10 years ago

Owner: changed from nobody to you-n-g
Status: newassigned

comment:4 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In f0c7a6f36005d489e049236922abe0bd3a3eac2c:

Fixed #23955 -- Corrected formset fields in topic guide.

comment:5 by Tim Graham <timograham@…>, 10 years ago

In 58e0d6bdbc2f7db6c7377bcdaa3d4bd23f119d15:

[1.7.x] Fixed #23955 -- Corrected formset fields in topic guide.

Backport of f0c7a6f36005d489e049236922abe0bd3a3eac2c from master

comment:6 by Tim Graham <timograham@…>, 10 years ago

In fdbe038ced67f567853cde4ea154747f5074344f:

[1.6.x] Fixed #23955 -- Corrected formset fields in topic guide.

Backport of f0c7a6f36005d489e049236922abe0bd3a3eac2c from master

comment:7 by Claire DeMars, 9 years ago

Resolution: fixed
Status: closednew

Hello,
{{form.id}} is actually necessary for inline formsets (and probably also model formsets, but I haven't tested it)

form.id is not displayed, but omitting it gives a MultiValueDict error and prevents saving when you try to save a formset having more than 1 form (which is the whole point of formsets)

Sources:

  1. personal experience
  2. this stack exchange post http://stackoverflow.com/questions/15980475/multivaluedictkeyerror-in-django-modelformset-factory

Thanks

comment:8 by Tim Graham, 9 years ago

Resolution: fixed
Status: newclosed

This example isn't for model formsets or inline formsets. #9704 is an open ticket about mentioning form.id.

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