35👍
(this thread is old but still could be googled)
you can use models.Q
with "~" as follows:
Table.objects.filter(~Q(title__in=myListOfTitles))
this method specially is helpful when you have multiple conditions.
👤omid
- [Django]-Multiple Database Config in Django 1.2
- [Django]-Default filter in Django admin
- [Django]-Django auto_now and auto_now_add
- [Django]-Best practices for getting the most testing coverage with Django/Python?
- [Django]-Django Admin Form for Many to many relationship
- [Django]-Django 2.0 – Not a valid view function or pattern name (Customizing Auth views)
3👍
Django provides two options.
exclude(<condition>)
filter(~Q(<condition>))
Method 2 using Q() method
>>> from django.db.models import Q
>>> queryset = User.objects.filter(~Q(id__lt=5))
- [Django]-Render HTML to PDF in Django site
- [Django]-How to get the name of current app within a template?
- [Django]-Auto-create primary key used when not defining a primary key type warning in Django
Source:stackexchange.com