[Answered ]-How to filter a trasaction model in django

1👍

✅

Try to use Q objects, like so:

from django.db.models import Q

def transactions_log(request):
    user = request.user
    transactions = Transaction.objects.filter(Q(sender=user) | Q(receiver=user))
    return render(request, "transaction.html", {"transactions": transactions})

Leave a comment