'RuntimeWarning: DateTimeField received a naive datetime for auto_now

We're using Django 1.10

We're getting a lot of this warning:

RuntimeWarning: DateTimeField Item.updated_at received a naive datetime (2018-05-01 12:35:18.213471) while time zone support is active.
RuntimeWarning)

I read a lot of answers about that questions, but in that case we're not settings the date manually. That field (Item.updated_at) is set as

auto_now=True

Is there a way to make 'auto_now' not naive?

This is part of the model:

class BaseModel(models.Model):

    id = models.UUIDField(default=uuid.uuid4, editable=False, db_index=True, unique=True, primary_key=True)
    created_by = models.CharField(max_length=200)
    created_at = models.DateTimeField(db_index=True, auto_now_add=True)
    updated_by = models.CharField(max_length=200)
    updated_at = models.DateTimeField(db_index=True, auto_now=True)

Thanks

EDIT: Could it be related to the factories we're using in tests? For example:

class ItemFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Item

    title = "Fake item title"
    identifier = factory.Sequence(lambda n: n)
    status_id = Status.Open['id']
    due_date = None
    updated_by = "Fake updater"
    updated_at = timezone.now()


Solution 1:[1]

From Django Doc Problem is not in the settings. Hope it will fix your problem

from django.utils import timezone
import datetime

datetime.datetime.now(tz=timezone.utc)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Antu