views:

147

answers:

1

I'm working on a localized Django app with a simple forum. Some posts' timestamps show up as if they were posted 7 hours earlier. What's weird is that it happens to some users, sometimes (a user may post once and it's OK, posts again and it's wrong).

settings.py:

TIME_ZONE = 'Europe/Prague'
LANGUAGES =  ( ('cs-cz', _('Czech')), )
DATABASE_ENGINE = 'sqlite3'

model:

class Post(models.Model):
    created = models.DateTimeField(auto_now_add=True)

Running on Apache with mod_wsgi.

+3  A: 

As referenced in other post you cite, see:

http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Timezone%5Fand%5FLocale%5FSettings

The issue is when you have multiple applications running in same server process which want different timezone settings. This is because TZ is a global process environment. Which ever application got to set it last will take precedence over all the others.

Use daemon mode of mod_wsgi and run any Python web applications which require different timezone settings to other applications in their own daemon process group. That way they will not interfere with each other.

Graham Dumpleton