Closed Steven-Chan closed 2 years ago
I plan to display a follower count in the question list page, which is calculated from the follower relationship between users and questions.
I don't think it matches the issue. This is more like data aggregation instead.
By default, the detail page shows:
TextField
, DateField
,...)ForeignKey
, OneToOneField
)Fields are listed in same order as in model.py
, and all texts are html escaped before rendering.
The detail page does not show:
ManyToManyField
)related_name
, e.g.: question_set
)To show fields/data with multiple values and customize what and how data is rendered, we could create a subclass of DetailModelView
and overwrite its get_object_data()
function which returns a generator of 2-tuples (key-value pairs). Use django.utils.safestring.mark_safe()
to mark strings suitable for HTML rendering.
I plan to display a follower count in the question list page, which is calculated from the follower relationship between users and questions.