Opened 3 years ago

Last modified 3 years ago

#33527 closed Cleanup/optimization

remove unnecessary code from patch before in ModelAdmin inlines save. — at Initial Version

Reported by: Maxim Danilov Owned by: nobody
Component: contrib.admin Version: 4.0
Severity: Normal Keywords: modeladmin, inlinemodel
Cc: 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

i see in Patch from https://code.djangoproject.com/ticket/33111
was added:

form = ModelForm(request.POST, request.FILES, instance=obj)
formsets, inline_instances = self._create_formsets(request, form.instance if add else obj, change=not add)

it is all ok, but if we have:

form = ModelForm(request.POST, request.FILES, instance=obj)

this is superabundant:

form.instance if add else obj

i think, it should be:

form = ModelForm(request.POST, request.FILES, instance=obj)
formsets, inline_instances = self._create_formsets(request, form.instance, change=not add)
# or # formsets, inline_instances = self._create_formsets(request, obj, change=not add)

The same changes is possible to made in code-block for request.GET

Change History (0)

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