diff --git a/mayan/apps/documents/south_migrations/0027_move_filename_to_label.py b/mayan/apps/documents/south_migrations/0027_move_filename_to_label.py index 5d42cb11b3..8d8b810982 100644 --- a/mayan/apps/documents/south_migrations/0027_move_filename_to_label.py +++ b/mayan/apps/documents/south_migrations/0027_move_filename_to_label.py @@ -15,7 +15,8 @@ class Migration(DataMigration): # NOTE: This migration take a while. Maybe the use of F objects could # improve it. for document in orm.Document.objects.all(): - document.label = document.versions.order_by('timestamp').last().filename + if document.versions.order_by('timestamp').last(): + document.label = document.versions.order_by('timestamp').last().filename document.save() def backwards(self, orm):