TrangPham / django-admin-confirm

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

FieldDoesNotExist is raised when declaring custom form field in modelform #32

Open nortigo opened 3 years ago

nortigo commented 3 years ago

I found a bug at line: https://github.com/TrangPham/django-admin-confirm/blob/5a085012c5f52bc542a11290255799c0a7ab2ec0/admin_confirm/admin.py#L192

How to reproduce:

  1. Create a modelform
  2. Add a custom field not related to the model
  3. Try changing some of the fields and save

Actual result:

A FieldDoesNotExists exception is raised:

django.core.exceptions.FieldDoesNotExist: AidRequest has no field named 'resubmit'

Expected result:

Custom field should be ignored.

DonKannalie commented 2 years ago

Did you find a workaround?

nortigo commented 2 years ago

Dirty workaround would be adding a try...except.

Clean workaround would be having meta fields such as excluded and fields so we can skip non model fields, something similar to forms.

TrangPham commented 2 years ago

:) I'd be very happy to review a PR that adds the excluded and fields.

nortigo commented 2 years ago

I don't have the time at the moment but if someone wants to jump on it, be my guest :)