From f962a7e0fa4d256baab95dd915a93a41bc992319 Mon Sep 17 00:00:00 2001 From: Carl van Tonder Date: Tue, 20 Nov 2018 12:59:28 -0500 Subject: [PATCH] Fix remove_null_from_text_fields migration --- .../migrations/0069_remove_null_from_text_fields.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/map/migrations/0069_remove_null_from_text_fields.py b/apps/map/migrations/0069_remove_null_from_text_fields.py index d59b4ba..737e002 100644 --- a/apps/map/migrations/0069_remove_null_from_text_fields.py +++ b/apps/map/migrations/0069_remove_null_from_text_fields.py @@ -5,8 +5,6 @@ from __future__ import unicode_literals from django.db import migrations, models import multiselectfield.db.fields -from apps.map.models import CaseStudy - string_fields = [ 'additional_technical_details', 'associated_infrastructure', @@ -58,13 +56,17 @@ string_fields = [ def remove_nulls(apps, schema_editor): # We can't import the Person model directly as it may be a newer # version than this migration expects. We use the historical version. - study = apps.get_model('map', 'CaseStudy') + CaseStudy = apps.get_model('map', 'CaseStudy') for study in CaseStudy.objects.all(): for field in string_fields: if getattr(study, field) == None: setattr(study, field, '') - study.save() + try: + study.save() + except: + from pdb import set_trace; set_trace() + class Migration(migrations.Migration): @@ -74,5 +76,5 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython(remove_nulls), + migrations.RunPython(remove_nulls, migrations.RunPython.noop), ]