tags:

views:

129

answers:

1

I tried something like:

MyModel.objects.filter(year__week=1)

It doesn't work. For now, I calculate the first day and the last day of the week and then use gte and lte, but it's less than efficient given that SQL comes with a Week function.

+1  A: 

It seems that django DateField doesn't have week attribute, as weel as date object from Python. They have both year and month and also day, but not week attribute. I guess you need to translate week to day range and file a ticket on django website ;-)

gruszczy
That's what I'm doing right now, but it's so boring. Ok for the ticket.
e-satis
I can tell you what isnt: try writing a patch for django :-) This should be a lot of fun ;-)
gruszczy
Lol, yeah, as soon as I meet my deadlines I'll do it. Don't wait for me :-D
e-satis
You seem to have a lot of time to spend on SO, so maybe you find a little to code something for django ;-)
gruszczy
make sure you mark this answer as accepted.
Goose Bumper