FANDOM


This is the class for configuring the admin page for a the item list, as well as the item description page. All pages in this category define the attributes and methods of this class.

Never instantiatedEdit

It should be noted that this class only exists to be subclassed by the user for the purposes of defining settings for the admin application. This class or any subclasses are never instantiated by the user.


Code examplesEdit

First off, a ModelAdmin subclass is not necessary if all default settings are requested:

from django.contrib import admin
from myproject.myapp.models import Author
   
admin.site.register(Author)

The simplest example (equivalent to above):

from django.contrib import admin
from myproject.myapp.models import Author
   
class AuthorAdmin(admin.ModelAdmin):
    pass

admin.site.register(Author, AuthorAdmin)

With actual options selected:

from django.contrib import admin
from myproject.myapp.models import Author
   
class AuthorAdmin(admin.ModelAdmin):
    list_display = ('first_name', 'last_name', 'birthdate', )
    search_fields = ('last_name', )
    raw_id_fields = ('books', )
   
admin.site.register(Author, AuthorAdmin)

Subcategories

This category has only the following subcategory.

M