I have the following model field:
name = models.ForeignKey(User, unique=False, editable=False, limit_choices_to=
{'is_staff': False})
How can I limit the choices based on a specific group of users as opposed to limiting to specific users based on a flag. Is it possible to somehow limit choices based on auth_user_groups?
Thanks
Yes, you can limit choices based on groups, here is one example
user = models.ForeignKey(User, unique=False, limit_choices_to= Q( groups__name = 'GroupName') )
try this, it works!
For Django 1.9
limit_choices_to={'groups__name': 'My Group'}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With