Re: Limiting choices in a lookup by exclusion

2017-02-01 Thread Melvyn Sopacua
And there's 2 other options to consider: * The ne lookup is actually the first example in the documentation for custom lookups[1]. So you get its implementation for free and can consider adding it. * You can extend Field to add exclude_choices() which sets limit_choices_to to the

Re: Limiting choices in a lookup by exclusion

2017-01-31 Thread C. Kirby
django doesn't have an ne operator in the orm. You want to use a negated Q object for your limit_choices_to. try: from django.db.models import Q phone = models.ManyToManyField(Phone, limit_choices_to = ~Q(type_id = 'C')) On Wednesday, February 1, 2017 at 6:17:52 AM UTC+2, Gordon Burgess wrote:

Limiting choices in a lookup by exclusion

2017-01-31 Thread Gordon R. Burgess
I have this code, and with Django 1.10 it works as expected: class Location(models.Model): name = models.CharField(max_length = 32, unique = True) street = models.CharField(max_length = 32) detail = models.CharField(max_length = 32, blank = True, null = True) city =