Setup Django and Timezone follow server datetime (Ubuntu)


Here is quickfix to setup Django working with server timezone.

1. Set Server Timezone

Check by :

1
2
date
Mon Jan  5 10:54:38 WIB 2015

If this not correct or you want to change server timezone, then edit “/etc/timezone”

1
Asia/Jakarta

Then do :

1
2
sudo dpkg-reconfigure –frontend noninteractive tzdata
date

Now you should see the updated server time.

2. Django
We need to edit settings.py add edit this line:

1
2
TIME_ZONE = ‘Asia/Jakarta’
USE_TZ = True

Restart your django server (uwsgi or wsgi) and do testing


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.