Possible Duplicate:
How do you select between two dates with Django
I have django model that contains 2 fields – c_date and c_int. As I am really weak in creating queries… is there some way to fetch from db only those records that fulfill this: c_date+timedelta(days=c_int)=date.today? I would like to do it on DB level because it would be faster than fetching all records and comparing date for all of them.
You should use
QuerySet.extrafor constructing complexWHEREclauses. For your requirement in particular, you should check the availability of theDATEADDfunction for your database of choice.Although, depending on how big your data set is and how often you’d need to run this query, another option is to do a migration and simply compute the sum of the date and offset immediately as an instance is created–you can create a custom
ModelFormto continue allowing user’s to specifyc_intas an offset in days.