migration fix
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 4 Oct 2012 11:10:22 +0000 (13:10 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 4 Oct 2012 11:10:22 +0000 (13:10 +0200)
migdal/migrations/0005_auto__add_field_entry_changed_at__add_field_entry_published_at_pl__add.py

index 2110ee4..f8e8ee8 100644 (file)
@@ -25,11 +25,13 @@ class Migration(SchemaMigration):
 
         if not db.dry_run:
             for entry in orm['migdal.Entry'].objects.all():
+                update_info = {}
                 if entry.published_pl:
-                    entry.published_at_pl = entry.date
+                    update_info['published_at_pl'] = entry.date
                 if entry.published_en:
-                    entry.published_at_en = entry.date
-                entry.save()
+                    update_info['published_at_en'] = entry.date
+                update_info['changed_at'] = entry.date
+                orm['migdal.Entry'].objects.filter(pk=entry.pk).update(**update_info)
 
 
     def backwards(self, orm):