[Fixed]-Datetime Field Received a Naive Datetime

25👍

You can use faker as follows:

import factory
from django.utils import timezone


class PostFactory(factory.DjangoModelFactory):
    FACTORY_FOR = models.Post
    value = 42
    created = factory.Faker("date_time", tzinfo=timezone.get_current_timezone())

0👍

You need to change timezone in settings.py also.

When USE_TZ is False, this is the time zone in which Django will store all datetimes. When USE_TZ is True, this is the default time zone that Django will use to display datetimes in templates and to interpret datetimes entered in forms.

👤Nilesh

Leave a comment