[Answered ]-How to filter on two different fields in on a Django query?

1👍

To filter on multiple fields in the same filter you provide the lookups as separate keyword arguments. To filter on a relationship, like a ForeignKey, use double underscores to follow the relationship

item = "phone"
timestamp = 1640736000
History.objects.filter(timestamp=timestamp, item__name=item).exists()

Leave a comment