Is it common practice to create a “base” MyModelAdmin
for a project and have all your ModelAdmin
classes inherit from it, like this:
class MyModelAdmin(admin.ModelAdmin):
list_max_show_all = 500
list_per_page = 25
class Media:
js = (
settings.STATIC_URL + 'js/admin.js'
)
css = {
'all': (settings.STATIC_URL + 'css/admin.css',)
}
@admin.register(Book)
class BookAdmin(MyModelAdmin):
model = Book
...
@admin.register(Author)
class AuthorAdmin(MyModelAdmin):
model = Author
...
# This also inherits from django.contrib.auth.admin.UserAdmin
@admin.register(CustomUser)
class CustomUserAdmin(MyModelAdmin, UserAdmin):
model = CustomUser
...
This makes a lot of sense to me, but I haven’t seen any examples of it anywhere.