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 }}.
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 , 10 years ago
Easy pickings: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
Has patch: | set |
---|---|
Version: | 1.7 → master |
comment:3 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
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:
- personal experience
- this stack exchange post http://stackoverflow.com/questions/15980475/multivaluedictkeyerror-in-django-modelformset-factory
Thanks
comment:8 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This example isn't for model formsets or inline formsets. #9704 is an open ticket about mentioning form.id
.
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 calledid
).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!