Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#33822 closed Bug (fixed)

New FormSet.edit_only only set when formset created by modelformset_factory

Reported by: Claude Paroz Owned by: Shawn Dong
Component: Forms Version: 4.1
Severity: Release blocker Keywords:
Cc: Vlad, Shawn Dong Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

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

Change History (8)

comment:1 by Mariusz Felisiak, 2 years ago

Cc: Vlad added
Easy pickings: set
Triage Stage: UnreviewedAccepted

Agreed, we should set:

class BaseModelFormSet(BaseFormSet):
    model = None
    edit_only = False
    ...

Thanks for the report!

comment:2 by Shawn Dong, 2 years ago

Owner: changed from nobody to Shawn Dong
Status: newassigned

comment:3 by Shawn Dong, 2 years ago

Cc: Shawn Dong added
Triage Stage: AcceptedReady for checkin

comment:4 by Mariusz Felisiak, 2 years ago

Has patch: set
Needs tests: set
Triage Stage: Ready for checkinAccepted

"Ready for checkin" is set by a patch reviewer, not the patch author (see Triaging tickets). Also, a regression test is required.

comment:5 by Shawn Dong, 2 years ago

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

comment:6 by Mariusz Felisiak, 2 years ago

Needs tests: unset
Triage Stage: AcceptedReady for checkin

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 18c5ba0:

Fixed #33822 -- Fixed save() crash on model formsets when not created by modelformset_factory().

Thanks Claude Paroz for the report.

Regression in e87f57fdb8dcdabc452bd15abd015bf6c9b1f7a8.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

In 675d2239:

[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

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