开发者

How can display a FloatField in a Django admin column rounded to the nearest integer, without using a custom list_display?

It would be easy with a custom list_display, but that w开发者_如何学Pythonould cause me to lose the sorting ability according to that column.


The docs say this:

However, if an element of list_display represents a certain database field, you can indicate this fact by setting the admin_order_field attribute of the item.

So you should define your function to display the rounded value, but set admin_order_field to preserve the ordering capability.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜