[Answered ]-Add raw sql where clause to django queryset

2👍

Not answering your question, but you can query customers like this:

from django.db.models import Q

Customer.objects.filter(
    Q(subscription__start__lt=current_date),
    Q(subscription__end=None) | Q (subscription__end__gt=current_date)
).distinct()
👤vsd

0👍

In answer to the original question, one can use the QuerySet.extra() method to add raw SQL as explained in the docs

👤zakum1

Leave a comment