how to limit the foreignkey dropdown with constraints?

后端 未结 3 1252
星月不相逢
星月不相逢 2020-12-14 10:36

I have a database which keeps track of interaction between two different teams (represented in the admin interface by two different groups). For some fields, i have a foreig

相关标签:
3条回答
  • 2020-12-14 10:57

    To override the choices for a foreign key field in Django admin app, write a formfield_for_foreignkey method.

    0 讨论(0)
  • 2020-12-14 11:09

    You're looking for limit_choices_to.

    0 讨论(0)
  • 2020-12-14 11:16

    You can change the underlaying queryset for the form field: How do I filter ForeignKey choices in a Django ModelForm?

    0 讨论(0)
提交回复
热议问题