Hi,

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!
>>>

Best regards,
Ahmed Abdullah

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f6953f2e-f9a6-46c7-aec8-f337b772fc9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to