This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

django-inline-actions adds actions to the InlineModelAdmin and ModelAdmin changelist.

Project Description

django-inline-actions adds actions to the InlineModelAdmin and ModelAdmin changelist.



  1. Install django-inline-actions

    pip install django-inline-actions
  2. Add inline_actions to your INSTALLED_APPS.

Migration to 1.0.0

Version 1.0.0 adds support for the admin changelist. Since the django ModelAdmin already has its own action handling, this release introduces breaking changes. Basically action has been renamed to inline_action in all method and property names.

type old_name new_name
property actions inline_actions
method get_actions get_inline_actions
method render_actions render_inline_actions

Since an action can now be called from a ModelAdmin or an InlineAdmin the signature of each action has changed to def action_name(self, request, obj, parent_obj=None). See Integration for further details.

If you do not want to use inline_actions on a changelist, you must deactivate its rendering explicitly

class Foo(InlineActionsModelAdminMixin, admin.ModelADmin):
   inline_actions = None
   # ...


Add the InlineActionsModelAdminMixin to your ModelAdmin. If you want to have actions on your inlines, add the InlineActionMixin to your InlineModelAdmin. Each action is implemented as a method on the ModelAdmin/InlineModelAdmin and has the following signature

def action_name(self, request, obj, parent_obj=None)
  1. request - current request
  2. obj - instance on which the action was triggered
  3. parent_obj - instance of the parent model, only set on inlines

and should return None to return to the current changeform or a HttpResponse. Finally, add your method name to the inline_actions property. If you want to disable the Actions column, explicitly set inline_actions = None. To add your actions dynamically, you can use the method get_inline_actions(self, request, obj=None) instead.

This module is bundled with two actions for viewing (inline_actions.actions.ViewAction) and deleting (inline_actions.actions.DeleteAction). Just add these classes to your admin and you’re done.


Imagine a simple news application with the following

from django.contrib import admin
from inline_actions.admin import InlineActionsMixin
from inline_actions.admin import InlineActionsModelAdminMixin

from .models import Article, Author

class ArticleInline(InlineActionsMixin,
    model = Article
    inline_actions = []

    def has_add_permission(self):
        return False

class AuthorAdmin(InlineActionsModelAdminMixin,
    inlines = [ArticleInline]
    list_display = ('name',)

class AuthorAdmin(admin.ModelAdmin):
    list_display = ('title', 'status', 'author')

We now want to add two simple actions (view, unpublish) to each article within the AuthorAdmin. The view action redirects to the changeform of the selected instance

from django.core.urlresolvers import reverse
from django.shortcuts import redirect

class ArticleInline(InlineActionsMixin,
    # ...
    inline_actions = ['view']
    # ...

    def view(self, request, obj, parent_obj=None):
        url = reverse(
        return redirect(url)
    view.short_description = _("View")

Since unpublish depends on article.status we must use get_inline_actions to add this action dynamically.

from django.contrib import admin, messages
from django.utils.translation import ugettext_lazy as _

class ArticleInline(InlineActionsMixin,
    # ...
    def get_inline_actions(self, request, obj=None):
        actions = super(ArticleInline, self).get_inline_actions(request, obj)
        if obj:
            if obj.status == Article.PUBLISHED:
        return actions

    def unpublish(self, request, obj, inline_obj):
        inline_obj.status = Article.DRAFT, _("Article unpublished"))
    unpublish.short_description = _("Unpublish")

Adding inline_actions to the changelist works similar. See the sample project for further details (test_proj/blog/

Example Application

You can see django-inline-actions in action using the bundled test application test_proj. I recommend to use a virtualenv.

git clone
cd django-inline-actions/
pip install Django
pip install -e .
cd test_proj
./ migrate
./ createsuperuser
./ runserver

Open http://localhost:8000/admin/ in your browser and create an author and some articles.

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_inline_actions-1.0.0-py2.py3-none-any.whl (10.9 kB) Copy SHA256 Checksum SHA256 3.5 Wheel Nov 12, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting