# django-object-tools-admin
Add toolbar in every item line in django's changelist view, and on top of django's changeform view.
## Install
```
pip install django-object-toolbar-admin
```
## Usage
**pro/settings.py**
```
INSTALLED_APPS = [
...
'django_static_fontawesome',
'django_object_toolbar_admin',
...
]
```
- Add django_static_fontawesome and django_object_toolbar_admin applications in INSTALLED_APPS.
**app/admin.py**
```
from django.contrib import admin
from django_object_toolbar_admin.admin import DjangoObjectToolbarAdmin
from .models import Category
class CategoryAdmin(DjangoObjectToolbarAdmin, admin.ModelAdmin):
list_display = ["name", "django_object_toolbar", "my_toolbar"]
django_object_toolbar_changeform_buttons = [
"print",
"export",
"bye",
]
# define default toolbar
django_object_toolbar_buttons = [
"print",
"export",
'bye',
]
def print(self, obj):
return "/print"
print.icon = "fas fa-print"
print.title = "Print"
print.help_text = "Print the object information..."
def export(self, obj):
return "/export"
export.icon = "fas fa-save"
export.title = "Export"
# define my toolbar
def my_toolbar(self, obj):
return self.get_django_object_toolbar("my_toolbar_buttons", obj)
my_toolbar.short_description = "My Toolbar"
my_toolbar_buttons = [
"delete",
"say_hi",
]
def delete(self, obj):
return "/delete"
delete.icon = "fas fa-trash"
delete.title = "Delete"
def say_hi(self, obj):
return "javascript:alert('hi {}');".format(obj.pk)
say_hi.icon = "fas fa-music"
say_hi.title = "Say Hi!"
admin.site.register(Category, CategoryAdmin)
```
- Buttons in `django_object_toolbar_changeform_buttons` will display on top of changeform view.
- Buttons in `django_object_toolbar_buttons` or `my_toolbar_buttons` will display in every line in changelist view. You need to put `django_object_toolbar` or `my_toolbar` in `list_display`.
- A button can be a method of admin or a method of model instance.
- A button method returns the link of the button.
- A button method tasks extra configs:
- button.title
- button.icon
- button.help_text
- button.target
- button.klass
## Releases
### v0.1.0
- First release.
### v0.1.1
- Fix Button.from_dict calling problem.
- Add i18n.
- Add app_requires.
### v0.1.2
- Doc update.
Raw data
{
"_id": null,
"home_page": "",
"name": "django-object-toolbar-admin",
"maintainer": "Long Zheng",
"docs_url": null,
"requires_python": "",
"maintainer_email": "longzheng@zencore.cn",
"keywords": "django admin extentions,django object toolbar admin",
"author": "Long Zheng",
"author_email": "longzheng@zencore.cn",
"download_url": "https://files.pythonhosted.org/packages/10/9a/09a16fd541ac6b92737eac9debeb64b85a69128945e757b488d95cf8d2c5/django-object-toolbar-admin-0.1.2.tar.gz",
"platform": null,
"description": "# django-object-tools-admin\n\nAdd toolbar in every item line in django's changelist view, and on top of django's changeform view.\n\n## Install\n\n```\npip install django-object-toolbar-admin\n```\n\n## Usage\n\n**pro/settings.py**\n\n```\nINSTALLED_APPS = [\n ...\n 'django_static_fontawesome',\n 'django_object_toolbar_admin',\n ...\n]\n```\n\n- Add django_static_fontawesome and django_object_toolbar_admin applications in INSTALLED_APPS.\n\n**app/admin.py**\n\n```\nfrom django.contrib import admin\nfrom django_object_toolbar_admin.admin import DjangoObjectToolbarAdmin\nfrom .models import Category\n\nclass CategoryAdmin(DjangoObjectToolbarAdmin, admin.ModelAdmin):\n list_display = [\"name\", \"django_object_toolbar\", \"my_toolbar\"]\n\n django_object_toolbar_changeform_buttons = [\n \"print\",\n \"export\",\n \"bye\",\n ]\n # define default toolbar\n django_object_toolbar_buttons = [\n \"print\",\n \"export\",\n 'bye',\n ]\n\n def print(self, obj):\n return \"/print\"\n print.icon = \"fas fa-print\"\n print.title = \"Print\"\n print.help_text = \"Print the object information...\"\n \n def export(self, obj):\n return \"/export\"\n export.icon = \"fas fa-save\"\n export.title = \"Export\"\n\n # define my toolbar\n def my_toolbar(self, obj):\n return self.get_django_object_toolbar(\"my_toolbar_buttons\", obj)\n my_toolbar.short_description = \"My Toolbar\"\n\n my_toolbar_buttons = [\n \"delete\",\n \"say_hi\",\n ]\n\n def delete(self, obj):\n return \"/delete\"\n delete.icon = \"fas fa-trash\"\n delete.title = \"Delete\"\n\n def say_hi(self, obj):\n return \"javascript:alert('hi {}');\".format(obj.pk)\n say_hi.icon = \"fas fa-music\"\n say_hi.title = \"Say Hi!\"\n\nadmin.site.register(Category, CategoryAdmin)\n```\n\n- Buttons in `django_object_toolbar_changeform_buttons` will display on top of changeform view.\n- Buttons in `django_object_toolbar_buttons` or `my_toolbar_buttons` will display in every line in changelist view. You need to put `django_object_toolbar` or `my_toolbar` in `list_display`.\n- A button can be a method of admin or a method of model instance.\n- A button method returns the link of the button.\n- A button method tasks extra configs:\n - button.title\n - button.icon\n - button.help_text\n - button.target\n - button.klass\n\n## Releases\n\n### v0.1.0\n\n- First release.\n\n### v0.1.1\n\n- Fix Button.from_dict calling problem.\n- Add i18n.\n- Add app_requires.\n\n### v0.1.2\n\n- Doc update.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Add toolbar in every item line in django's changelist view, and on top of django's changeform view.",
"version": "0.1.2",
"project_urls": null,
"split_keywords": [
"django admin extentions",
"django object toolbar admin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d5db8d22205081054a7c6caebaa8adb1f77b241a93d9045fe38b208e95f82cc3",
"md5": "e808f8fd34358b6611e4acfa3cfaed01",
"sha256": "5906bbe8690034dba3aeede9688985b45e894dda89b503b51e9a6ededf05df3f"
},
"downloads": -1,
"filename": "django_object_toolbar_admin-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e808f8fd34358b6611e4acfa3cfaed01",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8074,
"upload_time": "2023-09-14T12:43:27",
"upload_time_iso_8601": "2023-09-14T12:43:27.318090Z",
"url": "https://files.pythonhosted.org/packages/d5/db/8d22205081054a7c6caebaa8adb1f77b241a93d9045fe38b208e95f82cc3/django_object_toolbar_admin-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "109a09a16fd541ac6b92737eac9debeb64b85a69128945e757b488d95cf8d2c5",
"md5": "849ecad019054ae75f5e65ed21d67319",
"sha256": "0698b0ecb38ea37f6aa1f137b12e079ba96f90368ea90bcd3d7ff9de87360102"
},
"downloads": -1,
"filename": "django-object-toolbar-admin-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "849ecad019054ae75f5e65ed21d67319",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7143,
"upload_time": "2023-09-14T12:43:28",
"upload_time_iso_8601": "2023-09-14T12:43:28.832642Z",
"url": "https://files.pythonhosted.org/packages/10/9a/09a16fd541ac6b92737eac9debeb64b85a69128945e757b488d95cf8d2c5/django-object-toolbar-admin-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-14 12:43:28",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "django-object-toolbar-admin"
}