I
I
iegor2015-07-26 04:27:33
Django
iegor, 2015-07-26 04:27:33

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

1 answer(s)
I
iegor, 2015-07-26
@iegor

You just need to specify the date display format: datetime|date:"d" , well, it's just better to read the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question