All Projects → TrangPham → django-admin-confirm

TrangPham / django-admin-confirm

Licence: other
AdminConfirmMixin is a mixin for ModelAdmin that adds confirmations to changes, additions and actions.

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to django-admin-confirm

Repoll
Redis管理平台Repoll,现已开源,基于redis3.x,支持单机、哨兵以及集群模式
Stars: ✭ 196 (+476.47%)
Mutual labels:  django-admin
django-clone
Controlled Django model instance replication.
Stars: ✭ 89 (+161.76%)
Mutual labels:  django-admin
django-admin-shell
Django/Python shell for django admin site.
Stars: ✭ 62 (+82.35%)
Mutual labels:  django-admin
Django Admin List Filter Dropdown
Use dropdowns in Django admin list filter
Stars: ✭ 215 (+532.35%)
Mutual labels:  django-admin
django-admin-search
Modal filter for django admin
Stars: ✭ 60 (+76.47%)
Mutual labels:  django-admin
django-export-action
Generic export action for Django's Admin
Stars: ✭ 47 (+38.24%)
Mutual labels:  django-admin
Simpleui
A modern theme based on vue+element-ui for django admin.一款基于vue+element-ui的django admin现代化主题。全球20000+网站都在使用!喜欢可以点个star✨
Stars: ✭ 2,418 (+7011.76%)
Mutual labels:  django-admin
PyShop
PyShop is an online Python Ecommerce website built with Django, SQLite and Bootstrap. A simple and lightweight ecommerce app easily deployable anywhere anytime with modules developed upon the inbuilt django admin.
Stars: ✭ 17 (-50%)
Mutual labels:  django-admin
djadmin
Djadmin is a django admin theme
Stars: ✭ 42 (+23.53%)
Mutual labels:  django-admin
django-yaaac
Ajax Autocomplete Django application
Stars: ✭ 13 (-61.76%)
Mutual labels:  django-admin
Django Flat Responsive
📱 An extension for Django admin that makes interface mobile-friendly. Merged into Django 2.0
Stars: ✭ 249 (+632.35%)
Mutual labels:  django-admin
django-admin-extra-urls
Single mixin class to easily add buttons on any Django ModelAdmin related page
Stars: ✭ 26 (-23.53%)
Mutual labels:  django-admin
django-sqlalchemy
Django ORM built on top of SQLalchemy core 2.0 for seamless integration of SQLAlchemy with Django 4.1+ PostgreSQL 14+ only for now. [pre POC now]
Stars: ✭ 101 (+197.06%)
Mutual labels:  django-admin
Django Admin Env Notice
Visually distinguish environments in Django Admin
Stars: ✭ 207 (+508.82%)
Mutual labels:  django-admin
django-learning-pathway
(Currently in development) Learning pathways for learning Django.
Stars: ✭ 35 (+2.94%)
Mutual labels:  django-admin
Django Suit
Modern theme for Django admin interface
Stars: ✭ 2,136 (+6182.35%)
Mutual labels:  django-admin
django-haystackbrowser
View and debug the data in your Haystack search indexes, from within the Django admin.
Stars: ✭ 36 (+5.88%)
Mutual labels:  django-admin
django-admin-charts
Create beautiful configurable charts from your models and display them on the django-admin index page or on django-admin-tools dashboard. The charts are based on models and criterias defined through admin interface and some chart parameters are configurable in live view.
Stars: ✭ 78 (+129.41%)
Mutual labels:  django-admin
django-quill
Easily use Quill.js in your django admin.
Stars: ✭ 54 (+58.82%)
Mutual labels:  django-admin
django-code-generator
Generate code from your Django models for faster development
Stars: ✭ 35 (+2.94%)
Mutual labels:  django-admin

Django Admin Confirm

PyPI Tests Status Coverage Status PyPI - Python Version PyPI - Django Version PyPI - License Status

AdminConfirmMixin is a mixin for ModelAdmin to add confirmations to change, add and actions.

Screenshot of Change Confirmation Page

Screenshot of Add Confirmation Page

Screenshot of Action Confirmation Page

It can be configured to add a confirmation page on ModelAdmin upon:

  • saving changes
  • adding new instances
  • performing actions

Typical Usage:

    from admin_confirm import AdminConfirmMixin

    class MyModelAdmin(AdminConfirmMixin, ModelAdmin):
        confirm_change = True
        confirmation_fields = ['field1', 'field2']

Disclaimer

Be aware that not all possible combinations of ModelAdmin have been tested, even if test coverage is high.

See testing readme for more details

Installation

Install django-admin-confirm by running:

pip install django-admin-confirm

Add to INSTALLED_APPS in your project settings before django.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 before admin_confirm in INSTALLED_APPS.

Configuration Options

Environment 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_TIMEOUT default: 1000
  • ADMIN_CONFIRM_CACHE_KEY_PREFIX default: admin_confirm__file_cache

Attributes:

  • confirm_change Optional[bool] - decides if changes should trigger confirmation
  • confirm_add Optional[bool] - decides if additions should trigger confirmation
  • confirmation_fields Optional[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_template Optional[string] - path to custom html template to use for change/add
  • action_confirmation_template Optional[string] - path to custom html template to use for actions

Note that setting confirmation_fields without setting confirm_change or confirm_add would not trigger confirmation for change/add. Confirmations for actions does not use the confirmation_fields option.

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) -> TemplateResponse
  • render_action_confirmation(self, request: HttpRequest, context: dict) -> TemplateResponse

Usage

Confirm Change:

    from admin_confirm import AdminConfirmMixin

    class MyModelAdmin(AdminConfirmMixin, ModelAdmin):
        confirm_change = True
        confirmation_fields = ['field1', 'field2']

This would confirm changes on changes that include modifications onfield1 and/or field2.

Confirm Add:

    from admin_confirm import AdminConfirmMixin

    class MyModelAdmin(AdminConfirmMixin, ModelAdmin):
        confirm_add = True
        confirmation_fields = ['field1', 'field2']

This would confirm add on adds that set field1 and/or field2 to a non default value.

Note: confirmation_fields apply to both add/change confirmations.

Confirm Action:

    from admin_confirm import AdminConfirmMixin

    class MyModelAdmin(AdminConfirmMixin, ModelAdmin):
        actions = ["action1", "action2"]

        def action1(modeladmin, request, queryset):
            # Do something with the queryset

        @confirm_action
        def action2(modeladmin, request, queryset):
            # Do something with the queryset

        action2.allowed_permissions = ('change',)

This would confirm action2 but not action1.

Action confirmation will respect allowed_permissions and the has_xxx_permission methods.

Note: AdminConfirmMixin does not confirm any changes on inlines

Contribution & Appreciation

Contributions are most welcome :) Feel free to:

  • address an issue
  • raise an issue
  • add more test cases
  • add feature requests

Your appreciation is also very welcome :) Feel free to:

  • star the project
  • open an issue just to share your thanks

Check out our development process if you're interested.

Support

If you are having issues, please let us know through raising an issue.

License

The project is licensed under the Apache 2.0 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].