Filter queryset by checking two columns if they are equal

models.py

class Entry(models.Model):
    paid = models.FloatField(blank=True, null=True)
    price = models.FloatField(blank=True, null=True)

I want to get all entries that have paid and price columns the same value. How can I achieve this?

x = 12
Entry.objects.get(paid=x, price=x)

Does this solve your problem??

I found a solution for this

from django.db.models import F

Entry.objects.filter(price=F('paid'))
Back to Top