django-no-queryset-admin-actions


Namedjango-no-queryset-admin-actions JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryExtension for the Django admin panel that makes it possible to add actions that do not require a queryset to run.
upload_time2024-10-03 07:10:52
maintainerMichał Pokusa
docs_urlNone
authorMichał Pokusa
requires_pythonNone
licenseMIT License Copyright (c) 2024 Michał Pokusa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords django admin action actions queryset no queryset empty selection items no items
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# django-no-queryset-admin-actions

<p float="left">
    <a href="https://pypi.org/project/django-no-queryset-admin-actions/">
        <img src="https://img.shields.io/pypi/v/django-no-queryset-admin-actions?color=0073b7"/>
    </a>
    <a href="https://www.djangoproject.com/">
        <img src="https://img.shields.io/badge/3.2.x, 4.x.x, 5.x.x-a?style=flat&logo=django&label=django&labelColor=0c4b33&color=616161">
    </a>
</p>

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](https://pypi.org/project/django-admin-action-forms/).

It does one thing and one thing only.

- [🔌 Installation](#-installation)
- [✏️ Example](#️-example)


## 🔌 Installation

1. Install using ``pip``:

    ```bash
    $ pip3 install django-no-queryset-admin-actions
    ```


2. Add `'django_no_queryset_admin_actions'` to your `INSTALLED_APPS` setting.
    ```python
    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 bypass that, and create actions that can be run without selecting any objects.

<img src="https://raw.githubusercontent.com/michalpokusa/django-no-queryset-admin-actions/main/resources/example.gif" width="100%"></img>

```python
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"]
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-no-queryset-admin-actions",
    "maintainer": "Micha\u0142 Pokusa",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django, admin, action, actions, queryset, no queryset, empty, selection, items, no items",
    "author": "Micha\u0142 Pokusa",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/61/40/50c7214fb3950defcda0a6ad9f30347d063509063e56aaadff5674105a3c/django_no_queryset_admin_actions-1.1.0.tar.gz",
    "platform": null,
    "description": "\n# django-no-queryset-admin-actions\n\n<p float=\"left\">\n    <a href=\"https://pypi.org/project/django-no-queryset-admin-actions/\">\n        <img src=\"https://img.shields.io/pypi/v/django-no-queryset-admin-actions?color=0073b7\"/>\n    </a>\n    <a href=\"https://www.djangoproject.com/\">\n        <img src=\"https://img.shields.io/badge/3.2.x, 4.x.x, 5.x.x-a?style=flat&logo=django&label=django&labelColor=0c4b33&color=616161\">\n    </a>\n</p>\n\nExtension for the Django admin panel that makes it possible to add actions that do not require a queryset to run.\n\nWorks with [django-admin-action-forms](https://pypi.org/project/django-admin-action-forms/).\n\nIt does one thing and one thing only.\n\n- [\ud83d\udd0c Installation](#-installation)\n- [\u270f\ufe0f Example](#\ufe0f-example)\n\n\n## \ud83d\udd0c Installation\n\n1. Install using ``pip``:\n\n    ```bash\n    $ pip3 install django-no-queryset-admin-actions\n    ```\n\n\n2. Add `'django_no_queryset_admin_actions'` to your `INSTALLED_APPS` setting.\n    ```python\n    INSTALLED_APPS = [\n        ...\n        'django_no_queryset_admin_actions',\n    ]\n    ```\n\n## \u270f\ufe0f Example\n\nLet'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 bypass that, and create actions that can be run without selecting any objects.\n\n<img src=\"https://raw.githubusercontent.com/michalpokusa/django-no-queryset-admin-actions/main/resources/example.gif\" width=\"100%\"></img>\n\n```python\nfrom django.contrib.admin import ModelAdmin, register, action\n\nfrom django_no_queryset_admin_actions import NoQuerySetAdminActionsMixin\n\n\n@register(ExternalOrder)\nclass ExternalOrderAdmin(NoQuerySetAdminActionsMixin, ModelAdmin):\n\n    ...\n\n    @action(description=\"Fetch external orders\")\n    def fetch_external_orders(self, request): # <- No `queryset` parameter\n        ...\n\n    actions = [\"fetch_external_orders\"]\n\n    no_queryset_actions = [\"fetch_external_orders\"]\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Micha\u0142 Pokusa  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Extension for the Django admin panel that makes it possible to add actions that do not require a queryset to run.",
    "version": "1.1.0",
    "project_urls": {
        "Repository": "https://github.com/michalpokusa/django-no-queryset-admin-actions"
    },
    "split_keywords": [
        "django",
        " admin",
        " action",
        " actions",
        " queryset",
        " no queryset",
        " empty",
        " selection",
        " items",
        " no items"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d85bb30034194e130bd3c3d72347b8b7fdc37ef0404b664452bce64eb72fd594",
                "md5": "33eeb4b2bf7cf39cc5b68429da8204e0",
                "sha256": "0f28711ca0a10fb3905cab5e67eb231ce4e179840a8944dab220b53cc5f5443d"
            },
            "downloads": -1,
            "filename": "django_no_queryset_admin_actions-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "33eeb4b2bf7cf39cc5b68429da8204e0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14968,
            "upload_time": "2024-10-03T07:10:51",
            "upload_time_iso_8601": "2024-10-03T07:10:51.371088Z",
            "url": "https://files.pythonhosted.org/packages/d8/5b/b30034194e130bd3c3d72347b8b7fdc37ef0404b664452bce64eb72fd594/django_no_queryset_admin_actions-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "614050c7214fb3950defcda0a6ad9f30347d063509063e56aaadff5674105a3c",
                "md5": "299a94b6fbb5280ee5aed65d40f27cbc",
                "sha256": "3789659b57f303356fe1179988edb8c4791a7a4044ebeeff0ade8518b3a72336"
            },
            "downloads": -1,
            "filename": "django_no_queryset_admin_actions-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "299a94b6fbb5280ee5aed65d40f27cbc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 625542,
            "upload_time": "2024-10-03T07:10:52",
            "upload_time_iso_8601": "2024-10-03T07:10:52.512877Z",
            "url": "https://files.pythonhosted.org/packages/61/40/50c7214fb3950defcda0a6ad9f30347d063509063e56aaadff5674105a3c/django_no_queryset_admin_actions-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-03 07:10:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "michalpokusa",
    "github_project": "django-no-queryset-admin-actions",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-no-queryset-admin-actions"
}
        
Elapsed time: 8.61854s