1👍
You can use ~
as the NOT
operator:
check = (
Q(Q(firstname__exact="") & ~Q(surname__exact="")) |
Q(~Q(firstname__exact="") & Q(surname__exact="")) |
Q(~Q(firstname__exact="") & ~Q(surname__exact=""))
)
Source:stackexchange.com