I'm on django 1.8 and i have a problem in filtering and return months from an object with date-time field and
here is my code :
Expense.objects.filter(is_done=True).dates('created_date','month',order='DESC')
The error is so confusing
'created_date' is a DateTimeField, not a DateField.
created_date
is a DateTimeField
, not a DateField
. You have to use datetimes() instead of dates() .
New code:
Expense.objects.filter(is_done=True).datetimes('created_date','month',order='DESC')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.