Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - How to specify 'NOT IN' in 'limit_choices_to'?

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.

customer = models.ForeignKey(Customer, limit_choices_to={'status__in': ['active']}) 
like image 504
Sivasubramaniam Arunachalam Avatar asked Nov 24 '10 15:11

Sivasubramaniam Arunachalam


1 Answers

Just used the Q object instead of a dictionary.

limit_choices_to = ~models.Q(status__in = ['xxxxxx']))
like image 72
Sivasubramaniam Arunachalam Avatar answered Sep 30 '22 12:09

Sivasubramaniam Arunachalam