oursky / django-material-demo

0 stars 3 forks source link

Display relational data #6

Closed Steven-Chan closed 2 years ago

Rubikium commented 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.

Steven-Chan commented 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.

Rubikium commented 2 years ago

By default, the detail page shows:

Fields are listed in same order as in model.py, and all texts are html escaped before rendering.

The detail page does not show:

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.