Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Mixin for adding class-based views to ModelAdmin

Project description

django-adminextraviews

https://travis-ci.org/fusionbox/django-adminextraviews.png?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 view is a subclass of ModelFormMixin (like CreateView, UpdateView), ExtraViewsMixin will wrap the form class with the admin center widgets. It will also set the model attribute if it’s not set.

Changelog

1.1.0 (2015-03-24)

  • Allow for use of different models [#1].

1.0.0 (2015-03-19)

  • First release on PyPI.

Project details


Release history Release notifications

This version
History Node

1.1.0

History Node

1.0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-adminextraviews-1.1.0.tar.gz (7.7 kB) Copy SHA256 hash SHA256 Source None Mar 24, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page