python config_error ai_generated true

django.core.exceptions.ImproperlyConfigured: USE_TZ is True but TIME_ZONE is not set

ID: python/django-timezone-aware-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2025-05-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

USE_TZ=True requires TIME_ZONE setting to be specified.

generic

中文

USE_TZ=True 需要指定 TIME_ZONE 设置。

Workarounds

  1. 95% success
    Set TIME_ZONE = 'UTC' or your local timezone in settings.py.
  2. 80% success
    If you don't need timezone support, set USE_TZ = False.

Dead Ends

Common approaches that don't work:

  1. 60% fail

    Setting USE_TZ=False disables timezone support, which may cause datetime inconsistencies.

  2. 80% fail

    Setting TIME_ZONE='' doesn't satisfy Django; must be a valid timezone string.