[Django] #21259: Wizard sets queryset instead of instance on InlineFormset

28 views
Skip to first unread message

Django

unread,
Oct 11, 2013, 9:56:15 PM10/11/13
to django-...@googlegroups.com
#21259: Wizard sets queryset instead of instance on InlineFormset
-----------------------------------+-----------------------------------
Reporter: banderkat@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.formtools | Version: master
Severity: Normal | Keywords: wizard, InlineFormSet
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
-----------------------------------+-----------------------------------
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]

--
Ticket URL: <https://code.djangoproject.com/ticket/21259>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 14, 2013, 6:35:57 AM10/14/13
to django-...@googlegroups.com
#21259: Wizard sets queryset instead of instance on InlineFormset
-------------------------------------+-------------------------------------

Reporter: banderkat@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.formtools | Version: master
Severity: Normal | Resolution:
Keywords: wizard, | Triage Stage: Accepted
InlineFormSet | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 1 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 1
* stage: Unreviewed => Accepted


Comment:

Tentatively accepting, however, a test case demonstrating the problem and
proving the fix works is necessary for this to be committed.

--
Ticket URL: <https://code.djangoproject.com/ticket/21259#comment:1>

Django

unread,
Oct 15, 2013, 12:38:50 PM10/15/13
to django-...@googlegroups.com
#21259: Wizard sets queryset instead of instance on InlineFormset
-------------------------------------+-------------------------------------

Reporter: banderkat@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.formtools | Version: master
Severity: Normal | Resolution:
Keywords: wizard, | Triage Stage: Accepted
InlineFormSet | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 1 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by kkillebrew):

Okay, I've added a test to the pull request.

https://github.com/django/django/pull/1726

--
Ticket URL: <https://code.djangoproject.com/ticket/21259#comment:2>

Django

unread,
Oct 16, 2013, 10:23:08 AM10/16/13
to django-...@googlegroups.com
#21259: Wizard sets queryset instead of instance on InlineFormset
-------------------------------------+-------------------------------------

Reporter: banderkat@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.formtools | Version: master
Severity: Normal | Resolution:
Keywords: wizard, | Triage Stage: Accepted
InlineFormSet | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_better_patch: 0 => 1
* needs_tests: 1 => 0


Comment:

Thanks, I left comments for improve on the PR. Please uncheck "Patch needs
improvement" when you update it.

--
Ticket URL: <https://code.djangoproject.com/ticket/21259#comment:3>

Django

unread,
Oct 16, 2013, 11:15:48 AM10/16/13
to django-...@googlegroups.com
#21259: Wizard sets queryset instead of instance on InlineFormset
-------------------------------------+-------------------------------------

Reporter: banderkat@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.formtools | Version: master
Severity: Normal | Resolution:
Keywords: wizard, | Triage Stage: Accepted
InlineFormSet | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by kkillebrew):

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'.

--
Ticket URL: <https://code.djangoproject.com/ticket/21259#comment:4>

Django

unread,
Oct 16, 2013, 1:09:44 PM10/16/13
to django-...@googlegroups.com
#21259: Wizard sets queryset instead of instance on InlineFormset
-------------------------------------+-------------------------------------

Reporter: banderkat@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.formtools | Version: master
Severity: Normal | Resolution:
Keywords: wizard, | Triage Stage: Accepted
InlineFormSet | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by timo):

I believe you will need to include:
{{{
class Meta:
app_label = 'formtools'
}}}
on the model.

--
Ticket URL: <https://code.djangoproject.com/ticket/21259#comment:5>

Django

unread,
Oct 16, 2013, 2:12:03 PM10/16/13
to django-...@googlegroups.com
#21259: Wizard sets queryset instead of instance on InlineFormset
-------------------------------------+-------------------------------------

Reporter: banderkat@… | Owner: nobody
Type: Bug | Status: new
Component: contrib.formtools | Version: master
Severity: Normal | Resolution:
Keywords: wizard, | Triage Stage: Accepted
InlineFormSet | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by kkillebrew):

* needs_better_patch: 1 => 0


Comment:

That worked! Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/21259#comment:6>

Django

unread,
Oct 17, 2013, 2:01:28 PM10/17/13
to django-...@googlegroups.com
#21259: Wizard sets queryset instead of instance on InlineFormset
-------------------------------------+-------------------------------------
Reporter: banderkat@… | Owner: nobody
Type: Bug | Status: closed
Component: contrib.formtools | Version: master
Severity: Normal | Resolution: fixed

Keywords: wizard, | Triage Stage: Accepted
InlineFormSet | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"7e5d7a76bf60564d39d25a101380e47da7f1e2f6"]:
{{{
#!CommitTicketReference repository=""
revision="7e5d7a76bf60564d39d25a101380e47da7f1e2f6"
Fixed #21259 -- Fixed formstools wizard for InlineFormSet.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21259#comment:7>

Reply all
Reply to author
Forward
0 new messages