Jonas
Jonas

Reputation: 534

Change timezone inside Django admin

I am using Django 1.8.6. Datetimes are stored inside a PostgreSQL database in UTC. Below are my project-wide settings:

USE_TZ = True
TIMEZONE = 'UTC'
USE_L10N = True

I wonder if it is possible for me to show the time in a specified timezone inside the Django admin? (I am the only user of the admin.) Thanks.

Upvotes: 1

Views: 3440

Answers (1)

madzohan
madzohan

Reputation: 11808

for example your model

class SomeModel(models.Model):
    datetime_filed = models.DateTimeField(default=timezone.now)
  1. Simplest solution is change settings.TIMEZONE to your local one (one of pytz.all_timezones) django will store datetime_filed with tzinfo=<UTC> but in all templates by default it will be localized ... in your apps templates you can use one of these template tags https://docs.djangoproject.com/en/dev/topics/i18n/timezones/#template-tags

...

Upvotes: 1

Related Questions