[Django] #33822: New FormSet.edit_only only set when formset created by modelformset_factory

30 views
Skip to first unread message

Django

unread,
Jul 4, 2022, 9:11:27 AM7/4/22
to django-...@googlegroups.com
#33822: New FormSet.edit_only only set when formset created by modelformset_factory
-------------------------------------------+------------------------
Reporter: Claude Paroz | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 4.1
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
The new `FormSet.edit_only` attribute (#26142) is only set from
`modelformset_factory`. So if you create a formset class in a different
way, the `edit_only` attribute is not set and a crash happens in the
`save()` method when referring to `if self.edit_only:`.

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

Django

unread,
Jul 4, 2022, 9:49:32 AM7/4/22
to django-...@googlegroups.com
#33822: New FormSet.edit_only only set when formset created by modelformset_factory
---------------------------------+------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* cc: Vlad (added)
* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Agreed, we should set:
{{{#!python
class BaseModelFormSet(BaseFormSet):
model = None
edit_only = False
...
}}}

Thanks for the report!

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

Django

unread,
Jul 4, 2022, 1:22:32 PM7/4/22
to django-...@googlegroups.com
#33822: New FormSet.edit_only only set when formset created by modelformset_factory
---------------------------------+------------------------------------
Reporter: Claude Paroz | Owner: shawnxd
Type: Bug | Status: assigned

Component: Forms | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by shawnxd):

* owner: nobody => shawnxd
* status: new => assigned


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

Django

unread,
Jul 4, 2022, 1:51:18 PM7/4/22
to django-...@googlegroups.com
#33822: New FormSet.edit_only only set when formset created by modelformset_factory
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Shawn

Type: Bug | Status: assigned
Component: Forms | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Shawn):

* cc: Shawn (added)
* stage: Accepted => Ready for checkin


Comment:

PR: https://github.com/django/django/pull/15818

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

Django

unread,
Jul 4, 2022, 2:18:13 PM7/4/22
to django-...@googlegroups.com
#33822: New FormSet.edit_only only set when formset created by modelformset_factory
---------------------------------+------------------------------------

Reporter: Claude Paroz | Owner: Shawn
Type: Bug | Status: assigned
Component: Forms | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 0 => 1
* needs_tests: 0 => 1
* stage: Ready for checkin => Accepted


Comment:

"Ready for checkin" is set by a patch reviewer, not the patch author (see
[https://docs.djangoproject.com/en/dev/internals/contributing/triaging-
tickets/ Triaging tickets]). Also, a regression test is required.

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

Django

unread,
Jul 4, 2022, 4:41:14 PM7/4/22
to django-...@googlegroups.com
#33822: New FormSet.edit_only only set when formset created by modelformset_factory
---------------------------------+------------------------------------
Reporter: Claude Paroz | Owner: Shawn
Type: Bug | Status: assigned
Component: Forms | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Shawn):

got it. thanks for the reference doc. updated the pr:
https://github.com/django/django/pull/15818

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

Django

unread,
Jul 5, 2022, 1:20:09 AM7/5/22
to django-...@googlegroups.com
#33822: New FormSet.edit_only only set when formset created by modelformset_factory
-------------------------------------+-------------------------------------

Reporter: Claude Paroz | Owner: Shawn
Type: Bug | Status: assigned
Component: Forms | Version: 4.1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_tests: 1 => 0


* stage: Accepted => Ready for checkin


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

Django

unread,
Jul 5, 2022, 2:17:57 AM7/5/22
to django-...@googlegroups.com
#33822: New FormSet.edit_only only set when formset created by modelformset_factory
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Shawn
Type: Bug | Status: closed
Component: Forms | Version: 4.1
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"18c5ba07cc81be993941ecc2ecc17923b401b66f" 18c5ba0]:
{{{
#!CommitTicketReference repository=""
revision="18c5ba07cc81be993941ecc2ecc17923b401b66f"
Fixed #33822 -- Fixed save() crash on model formsets when not created by
modelformset_factory().

Thanks Claude Paroz for the report.

Regression in e87f57fdb8dcdabc452bd15abd015bf6c9b1f7a8.
}}}

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

Django

unread,
Jul 5, 2022, 2:18:40 AM7/5/22
to django-...@googlegroups.com
#33822: New FormSet.edit_only only set when formset created by modelformset_factory
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Shawn
Type: Bug | Status: closed
Component: Forms | Version: 4.1
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"675d2239cecf5da0da27b2176e03a262b6a9ebda" 675d2239]:
{{{
#!CommitTicketReference repository=""
revision="675d2239cecf5da0da27b2176e03a262b6a9ebda"
[4.1.x] Fixed #33822 -- Fixed save() crash on model formsets when not
created by modelformset_factory().

Thanks Claude Paroz for the report.

Regression in e87f57fdb8dcdabc452bd15abd015bf6c9b1f7a8.

Backport of 18c5ba07cc81be993941ecc2ecc17923b401b66f from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33822#comment:8>

Reply all
Reply to author
Forward
0 new messages