Django QuerySet next date
My model has a DateField. If I wi开发者_Python百科sh 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?
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)
精彩评论