Skip to main content

Mixin for adding class-based views to ModelAdmin

Project description

django-adminextraviews

https://travis-ci.org/fusionbox/django-adminextraviews?branch=master

Mixin for adding class-based views to ModelAdmin.

Why

Class-based views are really useful, but it’s difficult to add them to the admin center. This makes it easy to add class-based views to the Django admin.

Installation

Install django-adminextraviews:

pip install django-adminextraviews

Usage

Add the ExtraViewsMixin to your ModelAdmin and define the extra_views attribute.

from adminextraviews import ExtraViewsMixin

class MyModelAdmin(ExtraViewsMixin, admin.ModelAdmin):
    extra_views = [
        ('login_as_user', r'(?P<pk>\d+)/login/', LoginAsUserView),
    ]

Now you can use it like a normal view, you can reverse it.

>>> urlresolvers.reverse('admin:myapp_mymodel_login_as_user', kwargs={'pk': 12})
'/admin/myapp/mymodel/12/login/'

If your views have a form_class field, ExtraViewsMixin will wrap it with the admin widgets. It will also set the model attribute for you.

Changelog

1.0.0 (2015-03-19)

  • 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

django-adminextraviews-1.0.0.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file django-adminextraviews-1.0.0.tar.gz.

File metadata

File hashes

Hashes for django-adminextraviews-1.0.0.tar.gz
Algorithm Hash digest
SHA256 b4b4d431c279d6d80151081c6c1d9d8dc9e4ce65a763cb737eab01b969063a66
MD5 212dd44e11c71563441a8ef9a6d50f58
BLAKE2b-256 2db027604a311d265629340b7d69a7ad057ea46e077ef4bf39dd3f6ad6fb43c2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page