I have a Model:
class Authors(models.Model):
name = models.TextField()
person = models.ForeignKey(Person)
and query:
authors = Author.objects.filter(
(Q(name__iregex=r"\y{0}\y".format(s1)),
~Q(name__iregex=r"\y{0}\y".format(s2))
),
person=None).order_by('-id')
I am getting the error:
'Q' object has no attribute 'split'
why is this? i am not using split()
though.. the line of error is in this query line.
I think you need to join your Q()
filters with a logical operator like |
or &
.
authors = Author.objects.filter(
(Q(name__iregex=r"\y{0}\y".format(s1)) &
~Q(name__iregex=r"\y{0}\y".format(s2))
),
person=None).order_by('-id')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With