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, Indonesia

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

Recommended from Medium


Encrypted Terraform state with OpenStack and CEPH

Complete Guide to Unit Testing Durable Functions with VS Code

DIVA application walkthrough

How Thinking Mobile First Saved My Sanity

How to Hard Reset Oppo Neo 5 (2015)

Oppo Neo 5 (2015)

Amazon CloudFront: Delivering Content Globally

DevSecOps in a hybrid cloud environment

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, Indonesia

More from Medium

[Django] Django development notes (2) Templates

Introduction to Django Framework

introduction to Django Framework

Django Tutorial #2: URL Configuration

Django Forms Unchained