Skip to main content

Custom delete_selected action

Django delete_selected action in ModelAdmin not allow you to add operations before and after deleting objects from database by default.

Problem

Default delete_selected action using delete method of queryset so need to use pre_delete and post_delete signals.

Solution

Disable delete_selected action for all applications and models, but for some models this is crazy.

Installing

The easiest way to install package is with pip!

You can install from PyPI (for Django==1.4):

$ pip install django-custom_delete_selected

Or GitHub for Django==1.4:

$ pip install -e git+https://github.com/saippuakauppias/django-custom_delete_selected.git@django_v1.4#egg=custom_delete_selected

Or GitHub for Django==1.3.x:

$ pip install -e git+https://github.com/saippuakauppias/django-custom_delete_selected.git@django_v1.3.x#egg=custom_delete_selected

Or from source:

$ git clone https://github.com/saippuakauppias/django-custom_delete_selected.git
$ cd django-custom_delete_selected
$ python setup.py install

Usage

Import custom_delete_selected.admin.CustomDeleteSelected to extend ModelAdmin class and override delete_model method. For example:

from django.contrib import admin
from custom_delete_selected.admin import CustomDeleteSelected


class MyModelAdmin(CustomDeleteSelected, admin.ModelAdmin):

    # your code

    def delete_model(self, request, obj):
        # pre delete operations
        super(MyModelAdmin, self).delete_model(request, obj)
        # post delete operations

This code allow extends you deleting one object (when delete from change_form) and same objects (when delete from change_list).

Contributing

Feel free to fork, send pull requests or report bugs and issues on github.

Metadata

Release files for django-custom_delete_selected 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-custom_delete_selected 0.1
File Size Uploaded Provenance Actions
django-custom_delete_selected-0.1.tar.gz 4.1 kB Without provenance Details for django-custom_delete_selected-0.1.tar.gz

Release files / django-custom_delete_selected-0.1.tar.gz

Download URL django-custom_delete_selected-0.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
700827bfd4ef9253c83c699ce9018461cfe3cb45c34d53573df4614d72933ed0
BLAKE2b-256 checksum
How to use checksums
a8d112c9f92e33dcbb388d75d2b57d6727c981ee40214962e95582159ad107b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-custom_delete_selected 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page