The django.contrib packages
CONFIGURATION for admin app
First, make a few changes to your settings file:
- Add 'django.contrib.admin' to the INSTALLED_APPS setting. (The order of INSTALLED_APPS doesn’t matter, but we like to keep things alphabetical so it’s easy for a human to read.)
- Make sure INSTALLED_APPS contains 'django.contrib.auth', 'django.contrib.contenttypes' and 'django.contrib.sessions'. The Django admin site requires these three packages. (If you’re following along with our ongoing mysite project, note that we commented out these three INSTALLED_APPS entries in Chapter 5. Uncomment them now.)
- Make sure MIDDLEWARE_CLASSES contains 'django.middleware.common.CommonMiddleware','django.contrib.sessions.middleware.SessionMiddleware' and 'django.contrib.auth.middleware.AuthenticationMiddleware'. (Again, if you’re following along, note that we commented them out in Chapter 5, so uncomment them.)
Put 'django.contrib.admin' in your INSTALLED_APPS setting in order to use the admin application.s
run python manage.py syncdb.
REGISTRATION
Adding Your Models to the Admin Site
Within the books directory (mysite/books) App Directory
(need restart the server)
Beyond that, the Django admin site is just a Django application, with its own models, templates, views and URLpatterns.
dbshell
manage.py dbshell
(sqlite not supported, 'sqlite3' is not recognized as an internal or external command, operable program or batch file.)
list_display (by default: __unicode__())
change the display name in list in Django Adming
Select author to change
to be continued when you do the customization of the Admin Panel
Table of Content (index)
list_dispaly
list_filter
ordering
search_fileds # does not work with FK
No comments:
Post a Comment