raw_id_fields: How to show a name instead of id?

前端 未结 4 1590
北恋
北恋 2020-12-13 18:58

Customizing a Django Admin panel, I\'m using raw_id_fields to select a ForeignKey from a Model which has thousands of elements, because the default select-box drop-down is i

4条回答
  •  [愿得一人]
    2020-12-13 19:09

    I've also researched this and I don't think it's possible. I think the best you can do is display the unicode of the field next to the raw id field: http://djangosnippets.org/snippets/2108/

    Alternatively, you can display the unicode and a link to the value's corresponding admin change page: http://djangosnippets.org/snippets/2217/

提交回复
热议问题