from django db import models class myObj models Model date models Date

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
from django.db import models
class myObj(models.Model):
date = models.DateField()
>>> myObj.objects.filter(date__year__in=['2008','2009'])
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/x/.local/lib/python2.6/site-packages/django/db/models/manager.py", line 129, in filter
return self.get_query_set().filter(*args, **kwargs)
File "/home/x/.local/lib/python2.6/site-packages/django/db/models/query.py", line 498, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/home/x/.local/lib/python2.6/site-packages/django/db/models/query.py", line 516, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/home/x/.local/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1675, in add_q
can_reuse=used_aliases)
File "/home/x/.local/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1569, in add_filter
negate=negate, process_extras=process_extras)
File "/home/x/.local/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1885, in setup_joins
raise FieldError("Join on field %r not permitted. Did you misspell %r for the lookup type?" % (name, names[pos + 1]))
FieldError: Join on field 'date' not permitted. Did you misspell 'year' for the lookup type?