diff options
author | Dan McGee <dan@archlinux.org> | 2012-12-28 00:02:40 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-12-28 00:02:40 +0100 |
commit | e68a5073a6e8b9473f726734e0b51fdb0a42c14b (patch) | |
tree | 54155b70de13b217c5a2bbd95a1b193984fd4d69 | |
parent | 2b9519996a47fd1d978ccac36246f0245ad668fb (diff) | |
download | archweb-e68a5073a6e8b9473f726734e0b51fdb0a42c14b.tar.gz archweb-e68a5073a6e8b9473f726734e0b51fdb0a42c14b.tar.xz |
Fix "RuntimeWarning: DateTimeField received a naive datetime" warnings
When running tests, we can find old migrations that didn't use datetime
objects with timezones attached.
Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r-- | devel/migrations/0008_auto__add_field_userprofile_last_modified.py | 4 | ||||
-rw-r--r-- | main/migrations/0024_set_initial_flag_date.py | 4 | ||||
-rw-r--r-- | news/migrations/0003_new_date_columns_precision.py | 4 |
3 files changed, 7 insertions, 5 deletions
diff --git a/devel/migrations/0008_auto__add_field_userprofile_last_modified.py b/devel/migrations/0008_auto__add_field_userprofile_last_modified.py index 2695987..08972e1 100644 --- a/devel/migrations/0008_auto__add_field_userprofile_last_modified.py +++ b/devel/migrations/0008_auto__add_field_userprofile_last_modified.py @@ -3,12 +3,14 @@ import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models +from pytz import utc class Migration(SchemaMigration): def forwards(self, orm): + default = datetime.datetime(2000, 1, 1, 0, 0).replace(tzinfo=utc) db.add_column('user_profiles', 'last_modified', - self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2000, 1, 1, 0, 0)), + self.gf('django.db.models.fields.DateTimeField')(default=default), keep_default=False) def backwards(self, orm): diff --git a/main/migrations/0024_set_initial_flag_date.py b/main/migrations/0024_set_initial_flag_date.py index 5026f72..bd00879 100644 --- a/main/migrations/0024_set_initial_flag_date.py +++ b/main/migrations/0024_set_initial_flag_date.py @@ -1,14 +1,14 @@ # encoding: utf-8 -import datetime from south.db import db from south.v2 import DataMigration from django.db import models +from django.utils.timezone import now class Migration(DataMigration): def forwards(self, orm): orm.Package.objects.filter(needupdate=False).update(flag_date=None) - orm.Package.objects.filter(needupdate=True).update(flag_date=datetime.datetime.now()) + orm.Package.objects.filter(needupdate=True).update(flag_date=now()) def backwards(self, orm): orm.Package.objects.filter(flag_date__isnull=True).update(needupdate=False) diff --git a/news/migrations/0003_new_date_columns_precision.py b/news/migrations/0003_new_date_columns_precision.py index 21b6444..1c97f48 100644 --- a/news/migrations/0003_new_date_columns_precision.py +++ b/news/migrations/0003_new_date_columns_precision.py @@ -1,14 +1,14 @@ # encoding: utf-8 -import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models +from django.utils.timezone import now class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'News.last_modified' - db.add_column('news', 'last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=datetime.datetime.now(), db_index=True, blank=True), keep_default=False) + db.add_column('news', 'last_modified', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=now(), db_index=True, blank=True), keep_default=False) # Changing field 'News.postdate' db.alter_column('news', 'postdate', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True)) # Adding index on 'News', fields ['postdate'] |