Jean-Luc a écrit :

> Thank you for your help
>
> unfornunately no
> date_releve is always latest than date_operation or none
>
> I don't understand what appends
>
> jlT


Hi all
I check the code in
root/django/trunk/django/views/generic/date_based.py

124         # Calculate first and last day of month, for use in a
date-range lookup.
125         first_day = date.replace(day=1)
126         if first_day.month == 12:
127             last_day = first_day.replace(year=first_day.year + 1,
month=1)
128         else:
129             last_day = first_day.replace(month=first_day.month + 1)

last_day is the first day of next month

130         lookup_kwargs = {'%s__range' % date_field: (first_day,
last_day)}

range is inclusive

131
132         # Only bother to check current date if the month isn't in the
past and future objects are requested.
133         if last_day >= now.date() and not allow_future:
134             lookup_kwargs['%s__lte' % date_field] = now
135         object_list = queryset.filter(**lookup_kwargs)

so object_list include first of the next month


I propose this code (from line 124 to 135 of actual code)

# 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)
# here, last_day is the first day of the next month
last_day = last_day - datetime.timedelta(days=1)
# here, last_day is the last day of the same month
# if future objects are not requested.
if last_day >= now.date() and not allow_future:
        last_day = now.date()
lookup_kwargs = {'%s__range' % date_field: (first_day, last_day)}
object_list = queryset.filter(**lookup_kwargs)


Thank you all
jlT


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to