Django admin: Change selected box of related fields to autocomplete

前端 未结 5 1424
有刺的猬
有刺的猬 2020-12-04 16:55

We have some models that are have a user as a foreign key. But with about 25000 users in our system, it\'s a bit daunting to find the one we need.

Is there a solutio

5条回答
  •  眼角桃花
    2020-12-04 17:36

    The simplest out-of-the-box solution is to add the field to your ModelAdmin's raw_id_fields -- then you'll get a pop-up window in which you can use the built-in searching/filtering and pagination control's to find and select the object you're after.

    If you really want autocomplete, the other answers give a you reasonable starting point.

提交回复
热议问题