The workshop consists of a set of questions and answers designed to solidify your understanding of the material covered in this hour. Try answering the questions before looking at the answers.
1. | How can you limit the objects that are displayed in the change list by a word or phrase in the content of one or more fields? |
2. | How do you enable a group of object fields to be expanded or collapsed in the admin interface? |
3. | Is there a way to display information other than just the field data in the change list? |
1. | Add the search_fields attribute to the Admin class in the model. |
2. | Add the collapse class to the dictionary of the group defined in the fields attribute of the Admin class:
('Blogs', {'fields':('blogs',), 'classes': 'collapse'}), |
3. | Yes. You can define a function as a member of the model and then add the function to the list_display attribute of the Admin class for that model. The function's output is displayed in the change list. |