views:

30

answers:

1

My model has a DateField. If I wish to retrive all data that have a date after today, how will it be constructed? Eg. retreive all field with dates after today and stop at 31st december

today = datetime.date.today
Object.object.filter(date__day != today)

or will it be done using exclude?

+1  A: 

If I understood what you are trying to do, you should simply be able to filter like this:

today = datetime.date.today()
Object.objects.filter(date__gt=today, date__year=today.year)
Béres Botond
Yes, except you need to call `datetime.date.today()` - it's a method.
Daniel Roseman