0

I have a subclass of WeekArchiveClass:

class CallWeekArchiveView(WeekArchiveView):
    queryset = Call.objects.all()
    date_field = "dispatched"
    make_object_list = True
    allow_future = True
    allow_empty = True

When I look at /call/archive/2015/week/24/ I get dates in the range of 6/14 to 6/20 but according to http://www.epochconverter.com/date-and-time/weeknumbers-by-year.php the dates should range from Mon 6/8 to Sun 6/14.

The main thing I want to do is have the default of the current week for which I am attempting:

utc = pytz.timezone('UTC')
today = datetime.now(utc)
...
call_archive = '/call/archive/%d/week/%d' % ( today.year, today.isocalendar()[1] )

which gives call_archive as /call/archive/2015/week/25 which for today appears to be correct.

The problem comes up when I go to that url the page is empty as the date range appears to be wrong based on the example view of week/24.

So, why, when I go to /call/archive/2015/week/24 does the dates come up as 6/14 to 6/20?

And for reference I am at Django 1.8 and Python 3.4 but I suspect that is not part of the issue.

brechmos
  • 1,278
  • 1
  • 11
  • 22
  • 1
    Evidently this is related to http://stackoverflow.com/questions/5882405/get-date-from-iso-week-number-in-python but I still need to figure out how to make my case work properly. – brechmos Jun 20 '15 at 14:37
  • 1
    After reading through the above link I changed the today.isocalendar()[1] to today.strptime('%W') and added week_format = '%W' to the WeekArchiveView. It appears to be working. – brechmos Jun 20 '15 at 15:13

0 Answers0