I have a model with a field datetime as reference date and a field integer that holds the number of days to count from reference date, I need to filter out the rows whos reference_date + days is lesser than current date in django orm. I have tried with RawSQL, delegating the filter to mysql, but i need to access a column of the row, and i don't know how to include an F expresion inside a RawSql expresion, i tried joining strings but it doesn't work. Included my model description.
class ActionData(models.Model):
properties = models.ManyToManyField(Property, through='ActionProperties')
action = models.ForeignKey(Action, on_delete=models.CASCADE)
description = models.TextField(null=True)
days = models.IntegerField(default=0)
promocioned = models.BooleanField(default=False)
reference_date = models.DateTimeField(null=True)
modified_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
def __str__(self):
return str(self.pk) + self.action.name