How would I do the following SQL query in the Django ORM?
SELECT * FROM my_table WHERE date_added > date_created;
I'm guessing you don't have the date_created
available as a variable (as @tttthomasssss assumes) so it will be something like this:
from django.db import models
YourTable.objects.filter(date_added__gt=models.F('date_created')
Docs on F expressions: https://docs.djangoproject.com/en/dev/ref/models/expressions/#f-expressions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With