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 class BookAdmin(admin.ModelAdmin): verbose_name = "Books" 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.