I was getting this error when testing a project that I just set up
Exception Type: ImproperlyConfigured Exception Value: This query requires pytz, but it isn't installed.
After a little google search, I found myself getting this because in my settings I specified
USE_TZ = True
which, I believe, should inform my time zone about the project.
So, I ran sudo pip install pytz to install pytz so that I don't get this error. The problem is that now that pytz is installed, my models will not check when I try to do ./manage.py runserver and I get this error
Traceback (most recent call last): File "./manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line utility.execute() File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/core/management/__init__.py", line 354, in execute django.setup() File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/__init__.py", line 18, in setup from django.utils.log import configure_logging File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/utils/log.py", line 10, in <module> from django.views.debug import ExceptionReporter, get_exception_reporter_filter File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/views/debug.py", line 10, in <module> from django.http import (HttpResponse, HttpResponseServerError, File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/http/__init__.py", line 4, in <module> from django.http.response import (HttpResponse, StreamingHttpResponse, File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/http/response.py", line 13, in <module> from django.core.serializers.json import DjangoJSONEncoder File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/core/serializers/__init__.py", line 23, in <module> from django.core.serializers.base import SerializerDoesNotExist File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/core/serializers/base.py", line 6, in <module> from django.db import models File "/Users/user/.virtualenvs/app/lib/python3.4/site-packages/django/db/models/__init__.py", line 6, in <module> from django.db.models.query import Q, QuerySet, Prefetch
What's going on here? Why did I get this error? For me, it seems like the problem comes from pytz, but I'm not sure. Any help would be greatly appreciated.
Here is my model that worked great before installing pytz
from django.db import models from django.conf import settings
Edit: I added the views.py file
from .models import Item from django.views.generic import ListView, DetailView class ItemListView(ListView): model = Item class ItemDetailView(DetailView): model = Item def get_context_data(self, **kwargs):