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

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.