def archive_week(request, year, week, queryset, date_field, allow_future=False, **kwargs):
    try:
        date = datetime.date(*time.strptime(year+'-0-'+week, '%Y-%w-%U')[:3])
    except __HOLE__:
        raise Http404
    
    now = datetime.datetime.now()
    
    # Calculate first and last day of week, for use in a date-range lookup.
    first_day = date
    last_day = date + datetime.timedelta(days=7)
    lookup_kwargs = {
        '%s__gte' % date_field: first_day,
        '%s__lt' % date_field: last_day,
    }
    
    # Only bother to check current date if the week isn't in the past and future objects aren't requested.
    if last_day >= now.date() and not allow_future:
        lookup_kwargs['%s__lte' % date_field] = now
    queryset = queryset.filter(**lookup_kwargs).order_by('-' + date_field)
    
    return list_detail.object_list(request, queryset=queryset, **kwargs)
dataset/ETHPy150Open kylef-archive/lithium/lithium/views/date_based.py/archive_week