def archive_month(request, year, month, queryset, date_field, allow_future=False, month_format='%b', **kwargs):
    try:
        date = datetime.date(*time.strptime(year+month, '%Y'+month_format)[:3])
    except __HOLE__:
        raise Http404
    now = datetime.datetime.now()
    
    # Calculate first and last day of month, for use in a date-range lookup.
    first_day = date.replace(day=1)
    if first_day.month == 12:
        last_day = first_day.replace(year=first_day.year + 1, month=1)
    else:
        last_day = first_day.replace(month=first_day.month + 1)
    lookup_kwargs = {
        '%s__gte' % date_field: first_day,
        '%s__lt' % date_field: last_day,
    }
    
    # Only bother to check current date if the month isn't in the past and future objects are 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_month