I am following the django tutorial and was able to run the __year filter but when I try to use the month filter I get the error. Following is the commands that I have tried after starting python manage.py shell
>>> from django.utils import timezone
>>> current_year = timezone.now().year
>>> current_month = timezone.now().month
>>> print (current_year)
2014
>>> print (current_month)
9
>>> Choice.objects.filter(question__pub_date__year=current_year)
[<Choice: Not much>, <Choice: the sky>, <Choice: Just hacking again>]
>>> Choice.objects.filter(question__pub_date__month=current_month)
I get the following error:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python34\lib\site-packages\django\db\models\query.py", line 116, in _
_repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "C:\Python34\lib\site-packages\django\db\models\query.py", line 141, in _
_iter__
self._fetch_all()
File "C:\Python34\lib\site-packages\django\db\models\query.py", line 966, in _
fetch_all
self._result_cache = list(self.iterator())
File "C:\Python34\lib\site-packages\django\db\models\query.py", line 265, in i
terator
for row in compiler.results_iter():
File "C:\Python34\lib\site-packages\django\db\models\sql\compiler.py", line 70
0, in results_iter
for rows in self.execute_sql(MULTI):
File "C:\Python34\lib\site-packages\django\db\models\sql\compiler.py", line 77
5, in execute_sql
sql, params = self.as_sql()
File "C:\Python34\lib\site-packages\django\db\models\sql\compiler.py", line 10
9, in as_sql
where, w_params = self.compile(self.query.where)
File "C:\Python34\lib\site-packages\django\db\models\sql\compiler.py", line 80
, in compile
return node.as_sql(self, self.connection)
File "C:\Python34\lib\site-packages\django\db\models\sql\where.py", line 106,
in as_sql
sql, params = qn.compile(child)
File "C:\Python34\lib\site-packages\django\db\models\sql\compiler.py", line 80
, in compile
return node.as_sql(self, self.connection)
File "C:\Python34\lib\site-packages\django\db\models\lookups.py", line 149, in
as_sql
lhs_sql, params = self.process_lhs(qn, connection)
File "C:\Python34\lib\site-packages\django\db\models\lookups.py", line 304, in
process_lhs
sql, tz_params = connection.ops.datetime_extract_sql(self.extract_type, lhs,
tzname)
File "C:\Python34\lib\site-packages\django\db\backends\sqlite3\base.py", line
197, in datetime_extract_sql
raise ImproperlyConfigured("This query requires pytz, "
django.core.exceptions.ImproperlyConfigured: This query requires pytz, but it is
n't installed.
I am using windows 7 64 bit operating system Python 3.4.1 Django 1.7