Complete the code to register a model with the Django admin site.
from django.contrib import admin from .models import Product admin.site.[1](Product)
Use register to add your model to the admin interface so you can manage it easily.
Complete the code to customize the admin list display for a model.
from django.contrib import admin from .models import Book @admin.register(Book) class BookAdmin(admin.ModelAdmin): list_display = ([1])
The list_display expects a tuple of strings, so use parentheses and quotes like ('title', 'author').
Fix the error in the admin class to enable search functionality.
from django.contrib import admin from .models import Customer @admin.register(Customer) class CustomerAdmin(admin.ModelAdmin): search_fields = [1]
The search_fields attribute must be a list or tuple of strings, so use brackets or parentheses with quotes.
Fill both blanks to add filters and ordering in the admin interface.
from django.contrib import admin from .models import Order @admin.register(Order) class OrderAdmin(admin.ModelAdmin): list_filter = [1] ordering = [2]
Both list_filter and ordering accept tuples or lists. Here, tuples are used for clarity.
Fill all three blanks to customize the admin form with readonly fields and fieldsets.
from django.contrib import admin from .models import Profile @admin.register(Profile) class ProfileAdmin(admin.ModelAdmin): readonly_fields = [1] fieldsets = ( (None, {'fields': [2]), ('Advanced options', {'classes': ('collapse',), 'fields': [3]), )
readonly_fields can be a list or tuple; here a list is used. fieldsets groups fields; the first group has 'bio' and 'location', the second has 'created_at' and 'updated_at' with collapse style.