How to register a model twice in the Django admin?
Register a model twice in the Django admin

Note: If you want to read the blog series on Django Admin customization, then click here.
Suppose you have a Book model as given below.
# app_name/models.py
class Book(models.Model):
...
title = models.CharField(max_length=150)
is_active = models.BooleanField(default=True)
You might have tried registering a model twice by writing the same code twice, but it gave an error, there is a workaround to register a model twice, you just have to create a proxy model of the same model that you want to register, in this example we are going to create a proxy model of Book and then re-registered it.
# app_name/admin.py
from django.contrib import admin
from django.db import models
from app_name.models import Book
class BookProxy(Book):
class Meta:
proxy = True
@admin.register(Book) # First registration of a Book model in Django admin
class BookAdmin(admin.ModelAdmin):
verbose_name = "Books"
@admin.register(BookProxy) # Second registration of a Book model in Django admin
class BookProxyAdmin(admin.ModelAdmin):
verbose_name = "New Books"
Any thoughts? Write it down in the comments.
For more such crispy blogs daily, follow Dev.Junction, subscribe to our newsletter and get notified.
Social Links
About the author
Experienced Full Stack Software Engineer with 4+ Years of experience, proficient in Django and React, with expertise in Python, JavaScript and Typescript, also an author of Dev.Junction Blogs & YouTube Channel, expert in Python/Django, Rest Framework, ReactJS/NextJS and TypeScript, currently based in Pune, India.
Comments
Join the discussionNo comments yet. Be the first to comment.
Django admin tips and tricks
Django provides a great Admin panel rich in features and highly customizable, in this series of blogs we will be introduced to all such possible customizations and more.






