[Django]-Not naive datetime (tzinfo is already set)

3πŸ‘

βœ…

I think it’s a bug from django-celery when they upgrade their version. But by the way, put this in your init.py where your settings.py located.

# 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
πŸ‘€catherine

Leave a comment