(*, setting, **kwargs)
| 58 | |
| 59 | @receiver(setting_changed) |
| 60 | def update_connections_time_zone(*, setting, **kwargs): |
| 61 | if setting == "TIME_ZONE": |
| 62 | # Reset process time zone |
| 63 | if hasattr(time, "tzset"): |
| 64 | if kwargs["value"]: |
| 65 | os.environ["TZ"] = kwargs["value"] |
| 66 | else: |
| 67 | os.environ.pop("TZ", None) |
| 68 | time.tzset() |
| 69 | |
| 70 | # Reset local time zone cache |
| 71 | timezone.get_default_timezone.cache_clear() |
| 72 | |
| 73 | # Reset the database connections' time zone |
| 74 | if setting in {"TIME_ZONE", "USE_TZ"}: |
| 75 | for conn in connections.all(initialized_only=True): |
| 76 | try: |
| 77 | del conn.timezone |
| 78 | except AttributeError: |
| 79 | pass |
| 80 | try: |
| 81 | del conn.timezone_name |
| 82 | except AttributeError: |
| 83 | pass |
| 84 | conn.ensure_timezone() |
| 85 | |
| 86 | |
| 87 | @receiver(setting_changed) |
nothing calls this directly
no test coverage detected