Package: django-admin-confirm-cn
Django Admin ConfirmAdminConfirmMixin is a mixin for ModelAdmin to add confirmations to change, add and actions.It can be configured to add a confirmation page on ModelAdmin upon:saving changesadding new instancesperforming actionsTypical Usage:fromadmin_confirmimportAdminConfirmMixinclassMyModelAdmin(AdminConfirmMixin,ModelAdmin):confirm_change=Trueconfirmation_fields=['field1','field2']DisclaimerBe aware that not all possible combinations of ModelAdmin have been tested, even if test coverage is high.Seetesting readmefor more detailsInstallationInstall django-admin-confirm by running:pip install django-admin-confirmAdd to INSTALLED_APPS in your project settings beforedjango.contrib.admin:INSTALLED_APPS = [
    ...
    'admin_confirm',

    'django.contrib.admin',
    ...
]Note that this project follows the template override rules of Django.
To override a template, your app should be listed beforeadmin_confirmin INSTALLED_APPS.Configuration OptionsEnvironment Variables:Caching is used to cache files for confirmation. When change/add is submitted on the ModelAdmin, if confirmation is required, files will be cached until all validations pass and confirmation is received.ADMIN_CONFIRM_CACHE_TIMEOUTdefault: 1000ADMIN_CONFIRM_CACHE_KEY_PREFIXdefault: admin_confirm__file_cacheAttributes:confirm_changeOptional[bool]- decides if changes should trigger confirmationconfirm_addOptional[bool]- decides if additions should trigger confirmationconfirmation_fieldsOptional[Array[string]]- sets which fields should trigger confirmation for add/change. For adding new instances, the field would only trigger a confirmation if it's set to a value that's not its default.change_confirmation_templateOptional[string]- path to custom html template to use for change/addaction_confirmation_templateOptional[string]- path to custom html template to use for actionsNote that settingconfirmation_fieldswithout settingconfirm_changeorconfirm_addwould not trigger confirmation for change/add. Confirmations for actions does not use theconfirmation_fieldsoption.Method Overrides:If you want even more control over the confirmation, these methods can be overridden:get_confirmation_fields(self, request: HttpRequest, obj: Optional[Object]) -> List[str]render_change_confirmation(self, request: HttpRequest, context: dict) -> TemplateResponserender_action_confirmation(self, request: HttpRequest, context: dict) -> TemplateResponseUsageConfirm Change:fromadmin_confirmimportAdminConfirmMixinclassMyModelAdmin(AdminConfirmMixin,ModelAdmin):confirm_change=Trueconfirmation_fields=['field1','field2']This would confirm changes on changes that include modifications onfield1and/orfield2.Confirm Add:fromadmin_confirmimportAdminConfirmMixinclassMyModelAdmin(AdminConfirmMixin,ModelAdmin):confirm_add=Trueconfirmation_fields=['field1','field2']This would confirm add on adds that setfield1and/orfield2to a non default value.Note:confirmation_fieldsapply to both add/change confirmations.Confirm Action:fromadmin_confirmimportAdminConfirmMixinclassMyModelAdmin(AdminConfirmMixin,ModelAdmin):actions=["action1","action2"]defaction1(modeladmin,request,queryset):# Do something with the queryset@confirm_actiondefaction2(modeladmin,request,queryset):# Do something with the querysetaction2.allowed_permissions=('change',)This would confirmaction2but notaction1.Action confirmation will respectallowed_permissionsand thehas_xxx_permissionmethods.Note: AdminConfirmMixin does not confirm any changes on inlinesContribution & AppreciationContributions are most welcome :) Feel free to:address an issueraise an issueadd more test casesadd feature requestsYour appreciation is also very welcome :) Feel free to:star the projectopen an issue just to share your thanksCheck out ourdevelopment processif you're interested.SupportIf you are having issues, please let us know through raising an issue.LicenseThe project is licensed under the Apache 2.0 license.