Django Admin Custom Action

Default action and additional custom action

By default, Django admin provide delete model in action. We can add custom action.

Here some quick steps to add custom action.

Step 1: Preparation
a. Create virtualenv and start it.

> virtualenv venv
> venv\Scripts\activate

b. Install Django

(venv)> pip install django

c. Create Django Project

(venv)> django-admin startproject myproject

d. Goto Project Folder and Create Django Application

(venv)> cd myproject
(venv)/ myproject> python startapp myapp

e. Register Django App to Django Project
add ‘myapp’ in INSTALLED_APPS in myproject/

f. Initial Migrate

(venv)/ myproject> python migrate

g. Create superuser

(venv)/ myproject> python createsuperuser

type username, email, password and retype password.

Step 2: Create Book Model

a. Create Book Model
add book model in myapp/

b. Register model and add custom action
register book model in myapp/

action above will change selected book to ‘Out of Stock’.

c. Make migration and migrate

(venv)/ myproject> python makemigrations
(venv)/ myproject> python migrate

Step 3: Start Apps

(venv)/ myproject> python runserver

open open Book menu and add some book data and do some test with new custom action.




Software Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

I delivered a desktop app in a day

Go vs Python

Building a simple SQL interface for ElasticSearch

An Analogy Between Test Pyramid And Waste Pyramid

Create an Amazon EKS Fargate Cluster and Managed Node Group Using Terraform

Create an aws eks with fargate cluster and managed node group using terraform (IAC)

Drupal — Where to start?

5 Simple tips for boosting your Jenkins performance

Recap of AMA of Avalanche with Frontier

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adi Ramadhan

Adi Ramadhan

Software Engineer

More from Medium

Python : Django Web Framework

Django Tutorial #7: Models and Admin Panel

Django Queries (Part 1):

Introduction to Django Framework

introduction to Django Framework