Skip to main content

Automatically generates Django admin actions based on your model's fields

Project description

Django Auto Actions

PyPI PyPI - Python Version PyPI - License Ruff Coverage

Automatically generates basic Django admin actions based on your models' fields

Installation

Install the package using pip

pip install django-auto-actions

Usage

There are two ways to integrate django-auto-actions into your project:

  1. Using AutoActionsMixin (recommended way)
from django.contrib.admin import ModelAdmin
from django_auto_actions import AutoActionsMixin


@admin.register(YourModel)
class YourModelAdmin(AutoActionsMixin, ModelAdmin):
    ...
  1. Using AutoActionsModelAdmin instead of ModelAdmin
from django_auto_actions import AutoActionsModelAdmin


@admin.register(YourModel)
class YourModelAdmin(AutoActionsModelAdmin):
    ...

With either method, django-auto-actions will automatically generate admin actions for your model's BooleanFields, DateTimeFields, DateFields and TimeFields.

To exclude certain fields from having automatic admin actions generated, set the exclude_auto_actions class-level attribute.

@admin.register(YourModel)
class YourModelAdmin(AutoActionsMixin, ModelAdmin):
    exclude_auto_actions = ["is_example", "created_at"]

Example

Here's an example of what it might look like for a simple Homework model:
Example auto actions
And will display a success message like this:
Example success message

Running Tests

pip install -r requirements.txt
docker compose up -d
python runtests.py

Support & Contributing

If you like it, please consider giving this project a star. If you’re using the package, let me know! You can also create an issue for any problems or suggestions. PRs are always welcome!

Authors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_auto_actions-1.0.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

django_auto_actions-1.0.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file django_auto_actions-1.0.0.tar.gz.

File metadata

  • Download URL: django_auto_actions-1.0.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.7

File hashes

Hashes for django_auto_actions-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8cd311d5804c5243432cdc1459c172f9eebe7fe3b32695aaddcfafb4726e679a
MD5 2fb4d6cf79ca76627c9bbb8d5d96c3af
BLAKE2b-256 685e4b0ace2698c12aeb66c527d82f9da03a61c63f461b25467aeac7e230c9f0

See more details on using hashes here.

File details

Details for the file django_auto_actions-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_auto_actions-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1f96de0e53c1fc6e483d0d6f5fa2848e553850ccc43be3822fb68324d444f54
MD5 9248e9ad8ab2e24064221752c89c1d92
BLAKE2b-256 75d24f64bd73df65bdbe465e65a93b3e1c4969d754ec40b09b44c8cedbd14cc8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page