Django date.day 查询集查找
Django date.day queryset lookup
正在尝试根据 date.day
在查询集中获取一些对象
#Model
class Entry(models.Model):
...
from = models.DateField(default=datetime.date.today())
...
#view
day = 2
entryes = Entry.objects.all()
#works
day_entryes = entryes.filter(from__day=day)
#do not work
day_entryes = entryes.filter(from__day__lte=day)
我收到以下错误:
Join on field 'from' not permitted. Did you misspell 'day' for the lookup type?
为什么不起作用?
正在尝试根据 date.day
在查询集中获取一些对象#Model
class Entry(models.Model):
...
from = models.DateField(default=datetime.date.today())
...
#view
day = 2
entryes = Entry.objects.all()
#works
day_entryes = entryes.filter(from__day=day)
#do not work
day_entryes = entryes.filter(from__day__lte=day)
我收到以下错误:
Join on field 'from' not permitted. Did you misspell 'day' for the lookup type?
为什么不起作用?