This project has been archived by its maintainers, and is no longer receiving any updates.
pluggable django application that offers one single mixin class ExtraUrlMixin to easily add new url (and related buttons on the screen) to any ModelAdmin.
It provides two decorators link() and action().
link() is intended to be used for multiple records. It will produce a button in the change list view.
action() works on a single record. It will produce a button in the change form view.
Install
pip install admin-extra-urls
After installation add it to INSTALLED_APPS
INSTALLED_APPS = (
...
'admin_extra_urls',
)
How to use it
from admin_extra_urls.extras import ExtraUrlMixin, link, action
class MyModelModelAdmin(ExtraUrlMixin, admin.ModelAdmin):
@link() # /admin/myapp/mymodel/update_all/
def update_all(self, request):
...
...
@action() # /admin/myapp/mymodel/update/10/
def update(self, request, pk):
obj = self.get_object(pk=pk)
...
You don’t need to return a HttpResponse. The default behavior is:
with link() button is displayed in the ‘list’ view and the browser will be redirected to changelist_view
with action() button is displayed in the ‘update’ view and the browser will be redirected to change_view
link() / action() options
path |
None |
path url path for the action. will be the url where the button will point to. |
label |
None |
label for the button. by default the “labelized” function name |
icon |
‘’ |
icon for the button |
permission |
None |
permission required to use the button. Can be a callable (current object as argument). |
css_class |
“btn btn-success” |
extra css classes to use for the button |
order |
999 |
in case of multiple button the order to use |
visible |
lambda o: o and o.pk |
callable or bool. By default do not display “action” button if in add mode |
Integration with other libraries
django-import-export
@admin.register(Rule)
class RuleAdmin(ExtraUrlMixin, ImportExportMixin, BaseModelAdmin):
@link(label='Export')
def _export(self, request):
if '_changelist_filters' in request.GET:
real_query = QueryDict(request.GET.get('_changelist_filters'))
request.GET = real_query
return self.export_action(request)
@link(label='Import')
def _import(self, request):
return self.import_action(request)
Links
Stable |
||||
Development |
||||
Project home page: |
||||
Issue tracker: |
https://github.com/saxix/django-admin-extra-urls/issues?sort |
|||
Download: |
||||
Release files for admin-extra-urls 2.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| admin-extra-urls-2.2.0.tar.gz | 30.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| admin_extra_urls-2.2.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 45.0 kB
Release files / admin-extra-urls-2.2.0.tar.gz
| Download URL | admin-extra-urls-2.2.0.tar.gz |
|---|---|
| Size | 30.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b886ed045559f308d50f53f04b16a44fb2b1894e395dba6fb055306726a748f
|
|
BLAKE2b-256 checksum How to use checksums |
4c1161818521006f710c038f457302f12c99a27027d85b5e0dfbe977defbe107
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9
|
Release files / admin_extra_urls-2.2.0-py2.py3-none-any.whl
| Download URL | admin_extra_urls-2.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
75441038a916f0a5eb10d2c2a60c45aa2047b0e475d82a016408bad755bd9c78
|
|
BLAKE2b-256 checksum How to use checksums |
7fd84234832030edb4041d03641229c4c36a1aa750a1956a389a0df029148cbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.9
|