Django Custom Language and Time Zone

Adi Ramadhan
2 min readDec 21, 2020

--

Simple customization for language and timezone in django admin. By default django language is English and UTC Timezone. We can change to another language and timezone. Here’s the example, Language Bahasa Indonesia, timezone: GMT+7 (Jakarta’s Time). Official docs for Django internationalization and localization here. Focus in timezone, django use pytz library, and we can see official pytz doc here.

Default and Bahasa Indonesia Django Homepage

Step 1: Preparation, Create Django Project, Initial Migration
create virtualenv: virtualenv venv
start virtualenv: venv/Scripts/activate
install Django in virtualenv: pip install django==3.0
Create Django: django-admin startproject myproject
Go to myproject folder: cd myproject
Initial Migration: python manage.py migrate

Step 2: Create Superuser
Create superuser: python manage.py createsuperuser
Type username, email password and retype password

Step 3: Set Language and Time Zone in myproject/setting.py
Update LANGUAGE_CODE and TIME_ZONE setting.py

...LANGUAGE_CODE='id'TIME_ZONE = 'Asia/Jakarta'...

Note: list of language_code here. Time zone here.

Step 4: Run Server and Testing
Run Server: python manage.py runserver
Access: http://127.0.0.1:8000

Homepage
Admin Login Page
Admin Page

--

--