Skip to content

Commit

Permalink
mass_edit_view() should call get_form() on admin_obj
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Jul 29, 2022
1 parent 0cb88f9 commit 3ff26ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion massadmin/massadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def mass_change_view(
opts.verbose_name),
'key': escape(object_id)})

ModelForm = self.get_form(request, obj)
ModelForm = self.admin_obj.get_form(request, obj)
formsets = []
errors, errors_list = None, None
mass_changes_fields = request.POST.getlist("_mass_change")
Expand Down
10 changes: 9 additions & 1 deletion tests/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@ class CustomAdminWithCustomTemplate(admin.ModelAdmin):
change_form_template = "admin/change_form_template.html"


class CustomAdminWithGetFieldsets(admin.ModelAdmin):
class CustomAdminWithGetFieldsetsAncestor(admin.ModelAdmin):
"""
Ancestor that defines fieldsets
which should not be used by the mass_change_view()
"""
model = FieldsetsAdminModel
fieldsets = ()


class CustomAdminWithGetFieldsets(CustomAdminWithGetFieldsetsAncestor):

def get_fieldsets(self, request, obj=None):
return (
Expand Down

0 comments on commit 3ff26ba

Please sign in to comment.