KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I suppose time zone management was added to Django 1.4, so the problem is quite new. I used a simple model class Sample(models.Model): ... date_generated = models.DateTimeField(auto_now_add = True) When I try to retrieve a newly created record its fails. min_datetime = datetime.now() - timedelta(seconds = 300) sample = Sample.objects.get(date_generated__gte = min_datetime) and the server issues a warning. DateTimeField received a naive DateTime (2012-06-29 15:02:15.074000) while time zone support is active. I figured out two solutions to that problem. Disable time zone management in settings.py USE_TZ = False but this is not always desirable. 2. changing date_generated = models.DateTimeField(auto_now_add = True) to date_generated = models.DateTimeField(default=datetime.now()) is the solution that keeps time zone management working
Tags (comma-separated)
Save Edits
Cancel