Allow calling registered custom functions (system tools, script functions, etc.) via admin UI or manage.py command.
Project description
django-adminutilities
Allow calling registered custom functions (system tools, script functions, etc.) via admin UI or manage.py command.
The inspiration for this library comes from https://github.com/timonweb/django-clearcache.
Installation
Install the package via pip:
pip install django-adminutilities
Add adminutilities to your INSTALLED_APPS setting, make sure it’s above django.contrib.admin like this:
INSTALLED_APPS = [ 'adminutilities', 'django.contrib.admin', ]
Add adminutilities.middleware.GetAllAdminToolFunctionsMiddleware to your MIDDLEWARE setting like this:
MIDDLEWARE = [ ... 'adminutilities.middleware.GetAllAdminToolFunctionsMiddleware', ]
Add adminutilities to your urls.py:
urlpatterns = [ ... path('admin/', admin.site.urls), path('admin/adminutilities/', include('adminutilities.urls')), ]
Usage
Create a new file admin_tools.py in your app folder, and define your custom functions, for example:
from adminutilities.decorators import admin_tool @admin_tool def my_custom_function(): return 'Hello, world!'
Go to /admin/adminutilities/ and you will see the registered functions. If you click the function, it will execute the function and show the result.
You can also call the function via manage.py command, need to provide the full path of the function (app_name.function_name), for example:
python manage.py adminutilities main.my_custom_function
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.0 (2024-03-17)
First release on PyPI.
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
Built Distribution
File details
Details for the file django-adminutilities-0.1.7.tar.gz
.
File metadata
- Download URL: django-adminutilities-0.1.7.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ba959432e430e3be6f26f72f13e61169b889b7c2a10d9860126df8055c76c35 |
|
MD5 | 2eab6a6235fd6cd9b96643f7bbd565b0 |
|
BLAKE2b-256 | 436c261eed98eaf9d57fe5c0ab1a3171da3254434c2537f11b982e36b308eb2b |
File details
Details for the file django_adminutilities-0.1.7-py2.py3-none-any.whl
.
File metadata
- Download URL: django_adminutilities-0.1.7-py2.py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 638901fdf6188e21a03acb420136afd7fdcededebf7f493f2fc14849073593ed |
|
MD5 | 0ee99f2286e0a7370c4b3b519f18b880 |
|
BLAKE2b-256 | a7c865c4a5cbd69fb00d3684fe58820f6cfbefe2cd7fb5058fd220ac7555ed35 |