Answer the question
In order to leave comments, you need to log in
How to make sure that the time zone does not change?
Python 3.4 Django 1.8 hosting pythonanywhere.
The bottom line is that the time zone changes when the day attribute is applied to datetime.
From temlates:
{% for post in latest_posts_list %}
<\a href="{% url 'post:detail' post.id %}">
{{ post.datetime.day }} #no time zone attribute is what you want
From views:
def index(request):
latest_posts_list = Post.objects.order_by('-datetime')[:12]
context = {'latest_posts_list': latest_posts_list}
return render(request, 'post/index.html', context)
From models:
class Post(models.Model):
title = models.CharField(max_length=255)
datetime = models.DateTimeField(u'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question