Skip to main content
Archived

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

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)

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)

Source distribution for admin-extra-urls 2.2.0
File Size Uploaded
admin-extra-urls-2.2.0.tar.gz 30.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for admin-extra-urls 2.2.0
File Interpreter ABI Platform
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
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page