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

Use model meta to generate verbose name #54

Open dtcooper opened 7 months ago

dtcooper commented 7 months ago

Render field names of object rather than the word "None"

This is fix for issue https://github.com/TrangPham/django-admin-confirm/issues/53, since an object may not exist when rendering templates/admin/change_data.html - ie, if we're greating a new object when confirm_add = True is set on a ModelAdmin with the AdminConfirmMixin.

Also makes sure we send an actual object (not the string "None") to the base template, to remove other instances of the word "None" from the add view.

Uses capitalize on the string, as that seems to be the pattern in Django admin.

Fixes

Tested via:

image
TrangPham commented 7 months ago

Thanks for your contribution!

Do tests already exist for this? If not could you add a test case that would have failed before but now passes?

dtcooper commented 7 months ago

Ended up not using the project since it blew up for DecimalFields - so provided as-is! :)

Edit: my DecimalField blow up was my own fault. 😝

I'll look into adding tests.

TrangPham commented 7 months ago

Thanks. Let me know if you need support with either the tests or debugging your decimal issue.

If you found the reason you had issues with decimals, can you share that? I'll be able to help others if they face a similar issue if I know what happened.

dtcooper commented 7 months ago

Hi @TrangPham - I ended up not using django-admin-confirm for my project, so I'm not sure I'll have time ot prepare test cases. Thanks!