How to change Timezone in Django

In this tutorial, we will learn how to change or set timezones in Django.

In the new version of Django, it’s very easy to change the timezone.

In of your project, there is one variable named TIME_ZONE to define the timezone.

Steps to follow:-

  1. Create a project
  2. Open
  3. Search for TIME_ZONE
  4. Change the timezone.

Create a Project and open

First, we have to create a Django project. But before that, we need to get the names of timezone so to get this open the link –

Or you can simply use the pytz module in python to get the valid names of timezones.-

>>> import pytz 
>>> pytz.all_timezones_set

TIME_ZONE in Django

The default timezone is TIME_ZONE = 'UTC'.

You can change this in whichever timezone you want. For example,-

TIME_ZONE = 'Asia/Calcutta'.

For applying these changes we need to set the USE_TZ variable to TRUE.

I hope you find this tutorial helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *