Rendering datetime and proper formatting

I have a django project to keep track of tasks in a office enviroment. I have this model for tasks and it has a finish_date attribute that its assigned as soon i acces the route to done the desired task. I'm trying to use datetime and pytz to correctly format the date to the DateTimeField attribute.

Here's the view code:

task.data_conclusao=datetime.now().astimezone(pytz.timezone('America/Sao_Paulo'))
task.save()

It's saving the datetime but when i render it on the html, it just doesnt adjust to the timezone i set. Can anyone help me?

to fix the timezone issue on Django application,which ensures Use_Tz = True in settings of the application, and make sure to set your TIME_ZONE, and use the timezone template filter in the HTML to display the datetime in the timezone :

{% load tz %} {{ datatime_variable|timezone:"America/Sao_Paulo" }}

Back to Top