我在我的django应用程序中使用django芹菜,我遇到了这个错误:
ValueError: Not naive datetime (tzinfo is already set) in djcelery.utils in make_aware
如何解决此问题?
我认为这是django-celeron在升级版本时出现的错误。但顺便说一下,把它放在你的init.py中,你的settings.py所在的地方。
# Patch the djcelery/snapshot cause it's broken
import datetime
from django.utils.timezone import is_aware
import djcelery.snapshot
orig_maybe_make_aware = djcelery.snapshot.maybe_make_aware
def new_maybe_make_aware(value):
if isinstance(value, datetime.datetime) and is_aware(value):
return value
return orig_maybe_make_aware(value)
djcelery.snapshot.maybe_make_aware = new_maybe_make_aware