[Solved]-Django limit_choices_to on user group

13👍

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!

👤Ahsan

12👍

For Django 1.9

limit_choices_to={'groups__name': 'My Group'}

👤Seb

0👍

 limit_choices_to={'groups__pk': 2}

Leave a comment