Opened 11 years ago
Closed 11 years ago
#21259 closed Bug (fixed)
Wizard sets queryset instead of instance on InlineFormset
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | contrib.formtools | Version: | dev |
Severity: | Normal | Keywords: | wizard, InlineFormSet |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Because InlineFormSet
subclasses BaseModelFormSet
, the wizard thinks it's like any BaseModelFormSet
and incorrectly initializes the form by setting the form's queryset
instead of the form's instance
. An InlineFormSet
needs to have its instance set to the parent model object instead.
Currently, attempting to set self.instance
for the InlineFormSet
in the wizard's get_form_instance
results in an AttributeError
saying "object has no attribute 'none'" as the wizard attempts to set the form's queryset (instead of instance) with it's self.instance
.
I have a fix to propose here:
https://github.com/flibbertigibbet/django/commit/885798aa250544bd5c6d3a7325dc5c20c0795f2c
Change History (7)
comment:1 by , 11 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 11 years ago
Needs tests: | unset |
---|---|
Patch needs improvement: | set |
Thanks, I left comments for improve on the PR. Please uncheck "Patch needs improvement" when you update it.
comment:4 by , 11 years ago
Thanks for the notes. I'm having some issues with the test models. I put the new models.py in django.contrib.formtools.tests, and I see runtests.py says in the verbose output 'Creating table formtools_testmodel', but then the test fails with 'OperationalError: no such table: tests_poet'.
comment:5 by , 11 years ago
I believe you will need to include:
class Meta: app_label = 'formtools'
on the model.
comment:7 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Tentatively accepting, however, a test case demonstrating the problem and proving the fix works is necessary for this to be committed.