1from django.db.models import Q
2
3obj, created = Person.objects.filter(
4 Q(first_name='Bob') | Q(first_name='Robert'),
5).get_or_create(last_name='Marley', defaults={'first_name': 'Bob'})
6
1#There is Q objects that allow to complex lookups. Example:
2from django.db.models import Q
3
4Item.objects.filter(Q(creator=owner) | Q(moderated=False))
5
1#It is worth to note that it's possible to add Q expressions.
2from django.db.models import Q
3
4query = Q(first_name='mark')
5query.add(Q(email='mark@test.com'), Q.OR)
6query.add(Q(last_name='doe'), Q.AND)
7
8queryset = User.objects.filter(query)
9