Django

Code

Ticket #1480: 1480_time_zone.diff

File 1480_time_zone.diff, 4.8 kB (added by ramiro, 1 year ago)
  • a/django/conf/__init__.py

    old new  
    110110                new_installed_apps.append(app) 
    111111        self.INSTALLED_APPS = new_installed_apps 
    112112 
    113         if hasattr(time, 'tzset')
     113        if hasattr(time, 'tzset') and hasattr(self, 'TIME_ZONE') and self.TIME_ZONE
    114114            # Move the time zone info into os.environ. See ticket #2315 for why 
    115115            # we don't do this unconditionally (breaks Windows). 
    116116            os.environ['TZ'] = self.TIME_ZONE 
  • a/django/conf/project_template/settings.py

    old new  
    1919# Local time zone for this installation. Choices can be found here: 
    2020# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 
    2121# although not all choices may be available on all operating systems. 
     22# On Unix systems you can leave it undefined or set it to None if 
     23# you want the timezone to remain equal to the server's timezone. 
    2224# If running in a Windows environment this must be set to the same as your 
    2325# system time zone. 
    2426TIME_ZONE = 'America/Chicago' 
  • a/django/db/backends/postgresql/base.py

    old new  
    8282    def _cursor(self, settings): 
    8383        set_tz = False 
    8484        if self.connection is None: 
    85             set_tz = True 
     85            set_tz = hasattr(settings, 'TIME_ZONE') and settings.TIME_ZONE 
    8686            if settings.DATABASE_NAME == '': 
    8787                from django.core.exceptions import ImproperlyConfigured 
    8888                raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.") 
  • a/django/db/backends/postgresql_psycopg2/base.py

    old new  
    5353    def _cursor(self, settings): 
    5454        set_tz = False 
    5555        if self.connection is None: 
    56             set_tz = True 
     56            set_tz = hasattr(settings, 'TIME_ZONE') and settings.TIME_ZONE 
    5757            if settings.DATABASE_NAME == '': 
    5858                from django.core.exceptions import ImproperlyConfigured 
    5959                raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.") 
  • a/docs/settings.txt

    old new  
    10301030not necessarily the timezone of the server. For example, one server may serve 
    10311031multiple Django-powered sites, each with a separate time-zone setting. 
    10321032 
     1033This setting can also be left undefined or set to ``None`` for deployment 
     1034scenarios in which you need the timezone to remain in the server's timezone. 
     1035 
    10331036Normally, Django sets the ``os.environ['TZ']`` variable to the time zone you 
    10341037specify in the  ``TIME_ZONE`` setting. Thus, all your views and models will 
    1035 automatically operate in the correct time zone. However, if you're using the 
    1036 manual configuration option (see below), Django will *not* touch the ``TZ`` 
    1037 environment variable, and it'll be up to you to ensure your processes are 
    1038 running in the correct environment. 
     1038automatically operate in the correct time zone. However, Django will *not* 
     1039touch the ``TZ`` environment variable, and it'll be up to you to ensure your 
     1040processes are running in the correct environment in the following two scenarios: 
     1041 
     1042* If you leave the ``TIME_ZONE`` setting undefined or set it to ``None`` 
     1043* If you're using the manual configuration option (see below_) 
    10391044 
    10401045.. note:: 
    10411046    Django cannot reliably use alternate time zones in a Windows environment. 
     
    11051110      purely for performance. 
    11061111    * Don't reinvent an already-existing setting. 
    11071112 
     1113.. _below: 
     1114 
    11081115Using settings without setting DJANGO_SETTINGS_MODULE 
    11091116===================================================== 
    11101117 
     
    11351142 
    11361143Consequently, when configured via ``settings.configure()``, Django will not 
    11371144make any modifications to the process environment variables. (See the 
    1138 explanation of ``TIME_ZONE``, above, for why this would normally occur.) It's 
     1145explanation of TIME_ZONE_, above, for why this would normally occur.) It's 
    11391146assumed that you're already in full control of your environment in these cases. 
    11401147 
    11411148Custom default settings