From 90e08b4863dfaecafee5b151478bda4513b12e85 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Fri, 23 Mar 2012 19:29:40 -0500 Subject: Make all datetime objects fully timezone aware This is most of the transition to Django 1.4 `USE_TZ = True`. We need to ensure we don't mix aware and non-aware datetime objects when dealing with datetimes in the code. Add a utc_now() helper method that we can use most places, and ensure there is always a timezone attached when necessary. Signed-off-by: Dan McGee --- news/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'news') diff --git a/news/models.py b/news/models.py index 33d958e0..95026e1d 100644 --- a/news/models.py +++ b/news/models.py @@ -1,9 +1,10 @@ -from datetime import datetime - from django.db import models from django.contrib.auth.models import User from django.contrib.sites.models import Site +from main.utils import utc_now + + class News(models.Model): slug = models.SlugField(max_length=255, unique=True) author = models.ForeignKey(User, related_name='news_author', @@ -28,7 +29,7 @@ class Meta: def set_news_fields(sender, **kwargs): news = kwargs['instance'] - now = datetime.utcnow() + now = utc_now() news.last_modified = now if not news.postdate: news.postdate = now -- cgit v1.2.3-54-g00ecf