Django less than and greater than

To perform less than and greater than comparisons in Django, you can use the lt (less than) and gt (greater than) lookup filters in queries.

For example, suppose you have a model named Product with a field named price, and you want to retrieve products with prices less than 50:

from yourapp.models import Product

products_less_than_50 = Product.objects.filter(price__lt=50)

Similarly, to retrieve products with prices greater than 100:

products_greater_than_100 = Product.objects.filter(price__gt=100)

These queries use the filter() method along with __lt and __gt filters to fetch objects where the price field satisfies the less than or greater than condition specified.

Replace yourapp with the name of your Django application and adjust the model field names accordingly for your specific use case.