Fixed #34023 -- Added inline argument to user_deleted_form().

This binds the loop variable.
This commit is contained in:
Michał Pasternak 2022-09-24 12:16:20 +02:00 committed by GitHub
parent 1674c70525
commit 0f31d10c7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -2259,7 +2259,7 @@ class ModelAdmin(BaseModelAdmin):
formset_params = self.get_formset_kwargs(request, obj, inline, prefix)
formset = FormSet(**formset_params)
def user_deleted_form(request, obj, formset, index):
def user_deleted_form(request, obj, formset, index, inline):
"""Return whether or not the user deleted the form."""
return (
inline.has_delete_permission(request, obj)
@ -2270,7 +2270,7 @@ class ModelAdmin(BaseModelAdmin):
# data won't be in request.POST), unless the form was deleted.
if not inline.has_change_permission(request, obj if change else None):
for index, form in enumerate(formset.initial_forms):
if user_deleted_form(request, obj, formset, index):
if user_deleted_form(request, obj, formset, index, inline):
continue
form._errors = {}
form.cleaned_data = form.initial