There's a few options:
In settings.py
:
As one user commented, you technically can set TIME_ZONE = None
, and this will default to your physical computer time, this will be a real problem when trying to deploy a server or upload your project to a remote machine to serve it for you. For example, if you deployed your project on an amazon server with TIME_ZONE = None
, you may end up getting the system time of the physical machine hosting the server.
Instead, you must choose a valid tz
database time. If you look in the TZ
column on the following page: tz database timezones you may use any of these values.
Note: Manually setting a singular tz
database timezone may be limiting if your users are connecting from timezones other than yours (different parts of the country or world), or in timezones outside what you've manually set.
In this scenario, you either have to (1) have users registering supply their timezone, and alter your code, or (2) import django.utils timezone, see this page: django timezone module documentation. Another option is to (3) build a geolocator, which automatically grabs your users latitude and longitude position when they load your page and generates a timezone based on that information. Note that adjusting your timezone for users once you deploy your application is a more complicated process than setting a timezone for your local building and testing.
*//Answer edited to reflect a more holistic answer.