Re: [Django] #34084: ModelForms always set self.instance even when none passed in (was: Regression in Django 4.1 so ModelForms always set self.instance even when none passed in)

2 views
Skip to first unread message

Django

unread,
Oct 12, 2022, 2:06:16 AM10/12/22
to django-...@googlegroups.com
#34084: ModelForms always set self.instance even when none passed in
------------------------------+--------------------------------------
Reporter: Steven Mapes | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 4.1
Severity: Normal | Resolution: invalid
Keywords: modelform | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

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


Comment:

Thanks for the report, however this behavior was intentionally changed in
7ba6ebe9149ae38257d70100e8bfbfd0da189862 and it's documented in release
notes. Previously an empty queryset was implicitly returned for unsaved
instances now you need to protect your code and check `self.instance.pk`.

There is no change in the `ModelForm` behavior, `self.instance` was always
set.

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

Reply all
Reply to author
Forward
0 new messages