How to specify 'NOT IN' in 'limit_choices_to'? I just want to fetch all the customer details except if they are in one particular status.
如何在'limit_choices_to'中指定'NOT IN'?我只想获取所有客户详细信息,除非它们处于某种特定状态。
customer = models.ForeignKey(Customer, limit_choices_to={'status__in': ['active']})
1 个解决方案
#1
10
Just used the Q object instead of a dictionary.
刚刚使用Q对象而不是字典。
limit_choices_to = ~models.Q(status__in = ['xxxxxx']))
#1
10
Just used the Q object instead of a dictionary.
刚刚使用Q对象而不是字典。
limit_choices_to = ~models.Q(status__in = ['xxxxxx']))