2014-02-24 74 views
0

我想按日期篩選的出版物,與此代碼,但嘗試一下,我得到這個錯誤Django的錯誤驗證datetime.datetime,TZ格式

from datetime import datetime, timedelta 

from_date = datetime.now() - timedelta(days=7) 
data = Entry.objects.filter(date_publication=[from_date, datetime.now()]) 

[U「'[datetime.datetime(2014 ,2,24,18,27,9,451000),datetime.datetime(2014,2,17,18,27,9,451000)]'tiene un formato incorrecto。Debe ser del tipo YYYY-MM-DD HH: MM [:ss [.uuuuuu]] [TZ]。「]

class Productos(models.Model): 
    ... 
    date_publication =  models.DateTimeField(auto_now=True) 
     ... 

幫幫我! :)

回答

0

你可以嘗試使用:

data = Entry.objects.filter(date_publication__gte=from_date, date_publication__lte=datetime.now())