Skip to main content

Extension for the Django admin panel that makes it possible to add actions that do not require a queryset to run.

Project description

django-no-queryset-admin-actions

Extension for the Django admin panel that makes it possible to add actions that do not require a queryset to run.

Works with django-admin-action-forms.

It does one thing and one thing only.

🔌 Instalation

  1. Install using pip:

    $ pip3 install django-no-queryset-admin-actions
    
  2. Add 'django_no_queryset_admin_actions' to your INSTALLED_APPS setting.

    INSTALLED_APPS = [
        ...
        'django_no_queryset_admin_actions',
    ]
    

✏️ Example

Let's say you have an action that fetches external orders from an API. You don't need a queryset to run this action, but Django requires it by default. By using this extension, you can add bypass that, and create actions that can be run without selecting any objects.

from django.contrib.admin import ModelAdmin, register, action

from django_no_queryset_admin_actions import NoQuerySetAdminActionsMixin


@register(ExternalOrder)
class ExternalOrderAdmin(NoQuerySetAdminActionsMixin, ModelAdmin):

    ...

    @action(description="Fetch external orders")
    def fetch_external_orders(self, request): # <- No `queryset` parameter
        ...

    actions = ["fetch_external_orders"]

    no_queryset_actions = ["fetch_external_orders"]

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_no_queryset_admin_actions-1.0.1.tar.gz (625.1 kB view hashes)

Uploaded Source

Built Distribution

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