Providing Links to Other Objects
It’s quite common for objects to reference other objects through the use of foreign keys. You can point
list_display at a method that returns an HTML link. Inside
core/admin.py, modify the
CourseAdmin class as follows.
This query string modifies the
QuerySet used to populate the page. In the example shown here, the query string filters the
Person list to only show those objects that have a matching value in
Here, you can see the effect of this. The
course__id appears as a
2 in the query string and the matches are shown below. These filters support
QuerySet field lookups using double underscores (
You can access attributes of related objects as well as use filter modifiers like
__startswith. You can find the full details on what you can accomplish with the
list_display attribute in the Django admin documentation.
Become a Member to join the conversation.