def index(request):
context = {
'topics_unanswered': Topic.on_site.filter(topic_type=1, date_published__isnull=False, reply__isnull=True).count(),
'members_unapproved': User.objects.filter(profile__is_approved=False).count(),
'members_unverified_7days': User.objects.filter(profile__is_approved=False, date_joined__lte=timezone.now()-timezone.timedelta(days=7), profile__email_verified=False).count(),
'topics_today': Topic.on_site.filter(date_published__gte=timezone.now().date()).count(),
'replies_today': Reply.on_site.filter(date_published__gte=timezone.now().date()).count(),
'members_today': User.objects.filter(date_joined__gte=timezone.now().date()).count(),
}
return render(request, 'admincp/index.html', context)
...\lib\site-packages\django\db\models\fields\__init__.
py:1393: RuntimeWarning: DateTimeField Topic.date_published received a naive dat
etime (2016-06-09 00:00:00) while time zone support is active.
RuntimeWarning)
...\lib\site-packages\django\db\models\fields\__init__.
py:1393: RuntimeWarning: DateTimeField Reply.date_published received a naive dat
etime (2016-06-09 00:00:00) while time zone support is active.
RuntimeWarning)
...\lib\site-packages\django\db\models\fields\__init__.
py:1393: RuntimeWarning: DateTimeField User.date_joined received a naive datetim
e (2016-06-09 00:00:00) while time zone support is active.
RuntimeWarning)
[09/Jun/2016 13:38:09] "GET /admincp/ HTTP/1.1" 200 14002> py:1393: RuntimeWarning: DateTimeField User.date_joined received a naive datetim
> e (2016-06-09 00:00:00) while time zone support is active.
> RuntimeWarning)
>
> [09/Jun/2016 13:38:09] "GET /admincp/ HTTP/1.1" 200 14002
>
> I'm using timezone(), so why am I getting these warnings?
>
What is USE_TZ set to? If it is set to False (the default), you'll get naive datetime values from django.utils.timezone:
https://docs.djangoproject.com/en/1.9/ref/utils/#django.utils.timezone.now
You can use timezone.is_aware() to verify.
https://docs.djangoproject.com/en/1.9/ref/utils/#django.utils.timezone.is_aware
-James