Reputation: 15166
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 foreignkey to Users database, and i would like to limit the dropdown people to only the specific groups.
If anyone have any suggestions, it would be much appreciated!
Upvotes: 14
Views: 14014
Reputation: 308849
To override the choices for a foreign key field in Django admin app, write a formfield_for_foreignkey
method.
Upvotes: 3
Reputation: 50786
You can change the underlaying queryset for the form field: How do I filter ForeignKey choices in a Django ModelForm?
Upvotes: 3