如何在“limit_choices_to”中指定“NOT IN”?我只想获取所有客户详细信息,除非他们处于一种特定状态。
customer = models.ForeignKey(Customer, limit_choices_to={'status__in': ['active']})
最佳答案
只是使用 Q 对象而不是字典。
limit_choices_to = ~models.Q(status__in = ['xxxxxx']))
关于Django - 如何在 'NOT IN' 中指定 'limit_choices_to' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4268672/