sorting field in py_dj
时间:2010-05-06 来源:angelia_liu
Edit admin.py to make these changes:
from django.contrib import admin |
Here’s what we’ve done:
-
We created the class AuthorAdmin. This class, which subclasses django.contrib.admin.ModelAdmin, holds custom configuration for a specific admin model. We’ve only specified one customization — list_display, which is set to a tuple of field names to display on the change list page. These field names must exist in the model, of course.
-
We altered the admin.site.register() call to add AuthorAdmin after Author. You can read this as: “Register the Author model with the AuthorAdmin options.”
The admin.site.register() function takes a ModelAdmin subclass as an optional second argument. If you don’t specify a second argument (as is the case for Publisher and Book), Django will use the default admin options for that model.