Ticket #17882: 17882-better-fix-with-setting-changed-signal.diff

File 17882-better-fix-with-setting-changed-signal.diff, 764 bytes (added by aaugustin, 3 years ago)
  • django/test/signals.py

     
     1from django.db import close_connection
    12from django.dispatch import Signal
    23
    34template_rendered = Signal(providing_args=["template", "context"])
     
    34
    45setting_changed = Signal(providing_args=["setting", "value"])
     6
     7# Close the database connection to re-establish it with the proper time zone.
     8def close_connection_on_time_zone_change(**kwargs):
     9    if (kwargs['setting'] == 'USE_TZ'
     10        or (kwargs['setting'] == 'TIME_ZONE' and not settings.USE_TZ)):
     11        close_connection()
     12setting_changed.connect(close_connection_on_time_zone_change)
Back to Top