django-changelist-toolbar-admin


Namedjango-changelist-toolbar-admin JSON
Version 0.4.5 PyPI version JSON
download
home_pageNone
SummaryProvides custom button management function on changelist page of django admin site.
upload_time2024-05-26 02:40:55
maintainerZhao Sen
docs_urlNone
authorZhao Sen
requires_pythonNone
licenseMIT
keywords django admin extentions django-changelist-toolbar-admin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # django-changelist-toolbar-admin

Provides custom button management function on changelist page of django admin site.

## Install

```shell
pip install django-changelist-toolbar-admin
```

## Usage

**pro/settings.py**

```python
INSTALLED_APPS = [
    ...
    'django_static_fontawesome',
    'django_changelist_toolbar_admin',
    ...
]
```

- django_static_fontawesome is required, for already include the fontawesome css in Media's css settings.

**app/admin.py**

```python
from django.contrib import admin
from django_changelist_toolbar_admin.admin import DjangoChangelistToolbarAdmin
from .models import Category


class CategoryAdmin(DjangoChangelistToolbarAdmin, admin.ModelAdmin):
    list_display = ["name"]
    search_fields = ["name"]

    django_changelist_toolbar_buttons = [
        "export_button",
        "say_hi_button",
    ]

    def export_button(self, request):
        return "/export"
    export_button.title = "Export"
    export_button.icon = "fas fa-file-export"
    export_button.target = "_blank"
    
    def say_hi_button(self, request):
        return {
            "href": "javascript:alert('hi');",
            "title": "Say Hi",
            "icon": "fas fa-music",
        } 

admin.site.register(Category, CategoryAdmin)
```

- A button function must returns a Button instance, dict button info, or href.
- Another way is override `make_changelist_toolbar_button` get return the final buttons.

## Releases

### v0.4.5

- Add button classes support.

### v0.4.3

- Doc update.
- Add django-app-requires support.

### v0.4.0

- Fix document.
- Rename configuration item `changelist_toolbar_buttons` to `django_changelist_toolbar_buttons`.

### v0.3.0

- The main class rename to DjangoChangelistToolbarAdmin. Mixin is a very simple abstract class that provides helper functions, but DjangoChangelistToolbarAdmin is complex base admin, so we remove the mixin suffix.

### v0.2.0

- App rename to django_changelist_toolbar_admin.

### v0.1.0

- First release.



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-changelist-toolbar-admin",
    "maintainer": "Zhao Sen",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django admin extentions, django-changelist-toolbar-admin",
    "author": "Zhao Sen",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/47/99/63e0156a87422d8112eb372bfd373dd117f4deafae69dce17af77dd17085/django-changelist-toolbar-admin-0.4.5.tar.gz",
    "platform": null,
    "description": "# django-changelist-toolbar-admin\n\nProvides custom button management function on changelist page of django admin site.\n\n## Install\n\n```shell\npip install django-changelist-toolbar-admin\n```\n\n## Usage\n\n**pro/settings.py**\n\n```python\nINSTALLED_APPS = [\n    ...\n    'django_static_fontawesome',\n    'django_changelist_toolbar_admin',\n    ...\n]\n```\n\n- django_static_fontawesome is required, for already include the fontawesome css in Media's css settings.\n\n**app/admin.py**\n\n```python\nfrom django.contrib import admin\nfrom django_changelist_toolbar_admin.admin import DjangoChangelistToolbarAdmin\nfrom .models import Category\n\n\nclass CategoryAdmin(DjangoChangelistToolbarAdmin, admin.ModelAdmin):\n    list_display = [\"name\"]\n    search_fields = [\"name\"]\n\n    django_changelist_toolbar_buttons = [\n        \"export_button\",\n        \"say_hi_button\",\n    ]\n\n    def export_button(self, request):\n        return \"/export\"\n    export_button.title = \"Export\"\n    export_button.icon = \"fas fa-file-export\"\n    export_button.target = \"_blank\"\n    \n    def say_hi_button(self, request):\n        return {\n            \"href\": \"javascript:alert('hi');\",\n            \"title\": \"Say Hi\",\n            \"icon\": \"fas fa-music\",\n        } \n\nadmin.site.register(Category, CategoryAdmin)\n```\n\n- A button function must returns a Button instance, dict button info, or href.\n- Another way is override `make_changelist_toolbar_button` get return the final buttons.\n\n## Releases\n\n### v0.4.5\n\n- Add button classes support.\n\n### v0.4.3\n\n- Doc update.\n- Add django-app-requires support.\n\n### v0.4.0\n\n- Fix document.\n- Rename configuration item `changelist_toolbar_buttons` to `django_changelist_toolbar_buttons`.\n\n### v0.3.0\n\n- The main class rename to DjangoChangelistToolbarAdmin. Mixin is a very simple abstract class that provides helper functions, but DjangoChangelistToolbarAdmin is complex base admin, so we remove the mixin suffix.\n\n### v0.2.0\n\n- App rename to django_changelist_toolbar_admin.\n\n### v0.1.0\n\n- First release.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Provides custom button management function on changelist page of django admin site.",
    "version": "0.4.5",
    "project_urls": null,
    "split_keywords": [
        "django admin extentions",
        " django-changelist-toolbar-admin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c2691ea95946bdbe8a28ae6630898565cf50cbf81ed8ea902ede6c439e4ac4d5",
                "md5": "15479b9c637a5bc70bee62215522606c",
                "sha256": "1a147ac8c7c1addcab0555187306ce92d3a6dc0228c8e64b141e87b638862251"
            },
            "downloads": -1,
            "filename": "django_changelist_toolbar_admin-0.4.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "15479b9c637a5bc70bee62215522606c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6820,
            "upload_time": "2024-05-26T02:40:53",
            "upload_time_iso_8601": "2024-05-26T02:40:53.488233Z",
            "url": "https://files.pythonhosted.org/packages/c2/69/1ea95946bdbe8a28ae6630898565cf50cbf81ed8ea902ede6c439e4ac4d5/django_changelist_toolbar_admin-0.4.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "479963e0156a87422d8112eb372bfd373dd117f4deafae69dce17af77dd17085",
                "md5": "2553f2ae3b13283961a2fcac07c9855d",
                "sha256": "fd38cdb4ad11f2efb7305b7c77d6de644add34a3a1f9695b96050fbd927070de"
            },
            "downloads": -1,
            "filename": "django-changelist-toolbar-admin-0.4.5.tar.gz",
            "has_sig": false,
            "md5_digest": "2553f2ae3b13283961a2fcac07c9855d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6251,
            "upload_time": "2024-05-26T02:40:55",
            "upload_time_iso_8601": "2024-05-26T02:40:55.634385Z",
            "url": "https://files.pythonhosted.org/packages/47/99/63e0156a87422d8112eb372bfd373dd117f4deafae69dce17af77dd17085/django-changelist-toolbar-admin-0.4.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-26 02:40:55",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-changelist-toolbar-admin"
}
        
Elapsed time: 0.23665s