Let's say I have a model that looks like this:
class StockRequest(models.Model): amount_requested = models.PositiveIntegerField(null=True) amount_approved = models.PositiveIntegerField(null=True)
Is there a way to make a django request that will show me all the requests where there is some relationship between amount_requested and amount_approved for a specific object / row?
In SQL, it will be as simple as:
select * from stockrequest where amount_requested = amount_approved;
or
select * from stockrequest where amount_requested = amount_approved;
In Django, I'm not sure if this can be done, but I would suggest something like below (NOTE: the syntax is fully compiled and does not work).
StockRequest.objects.filter(amount_requested="__amount_approved")
Cory
source share