TrangPham / django-admin-confirm

AdminConfirmMixin is a mixin for ModelAdmin that adds confirmations to changes, additions and actions.
Other
129 stars 16 forks source link

Many-to-many fields do not trigger confirmation unless specified in "get_confirmation_fields" method #48

Open e-kondr01 opened 1 year ago

e-kondr01 commented 1 year ago

Describe the bug I use AdminConfirmMixin and admin.ModelAdmin, setting confirm_change = True. Fields that are not ManyToMany correctly trigger confirmation page. However, my ManyToManyField did not trigger it until I included it in the return value of get_confirmation_fields.

Expected behavior If no confirmation_fields are specified, then all model fields should trigger confirmation page, even ManyToManyField type ones.

Versions django-admin-confirm==1.0.0 python 3.11

Additional context There reason is this line: https://github.com/TrangPham/django-admin-confirm/blob/main/admin_confirm/admin.py#L58 ManyToManyFields do not appear in model._meta.fields

TrangPham commented 1 year ago

Ah thanks for such a great bug report!

I'd be very happy to review a change from you or others. Marking as a good starter ticket.

e-kondr01 commented 1 year ago

A futher note is that after you explicitly specify a M2M field in confirmation_fields, every save will trigger the confirmation page, even if no data has been changed.