I'm practicing Django v 1.8.6 (Writing your first Django app, part 1) and getting error when trying to import timezone, also I have installed pytz, when I try to use the import timezone package I'm getting ImportError.
My settings.py has USE_TZ set to true by default, also, I had to change the TIME_ZONE from UTC to Asia/Bahrain but still I'm getting the below error, kindly if anyone have advice on the below error?
>>> from polls.models import Question, Choice
>>> Question.objects.all()
[<Question: What's up?>, <Question: What's up?>]
>>> Question.objects.filter(id=1)
[<Question: What's up?>]
>>> Question.objects.filter(id=2)
[<Question: What's up?>]
>>> Question.objects.filter(id=3)
[]
>>> Question.objects.filter(question_text__startswith='What')
[<Question: What's up?>, <Question: What's up?>]
>>> from django.utils import timezone
>>> current_year = timezone.now().year
>>> Question.objects.get(pub_date__year=current_year)
Traceback (most recent call last):
File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 69, in h
andle
self.run_shell(shell=options['interface'])
File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\management\commands\shell.py", line 61, in r
un_shell
raise ImportError
ImportError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\manager.py", line 127, in manager_metho
d
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\abdullaha\AppData\Local\Programs\Python\Python35\lib\site-packages\django\db\models\query.py", line 338, in get
(self.model._meta.object_name, num)
polls.models.MultipleObjectsReturned: get() returned more than one Question -- it returned 2!
>>>