Friday, 23 August 2013

From Datefield get months in array in django qs

From Datefield get months in array in django qs

I have django model with DateField. If I need to get objects from certain
month I can do this:
objects = Model.objects.filter(date__month=8) and it works fine, but if i do:
objects = Model.objects.filter(date__month__in=[1, 2, 3]) I get error:
FieldError at /
Join on field 'date' not permitted. Did you misspell 'month' for the
lookup type?
Is there any way to do what I'm attempting?

No comments:

Post a Comment