from __future__ import unicode_literals

from django.db import migrations


def populate_default(apps, schema_editor):
    ScriptParameter = apps.get_model('wooey', 'ScriptParameter')
    for obj in ScriptParameter.objects.all():
        obj.default = obj._default
        obj.save()


class Migration(migrations.Migration):

    dependencies = [
        ('wooey', '0036_add-jsonfield'),
    ]

    operations = [
        migrations.RunPython(populate_default)
    ]

from __future__ import unicode_literals
import json

from django.db import migrations


def populate_default(apps, schema_editor):
    ScriptParameter = apps.get_model('wooey', 'ScriptParameter')
    for obj in ScriptParameter.objects.all():
        try:
            obj.default = json.loads(obj._default)
        except Exception:
            obj.default = obj._default
        obj.save()


class Migration(migrations.Migration):

    dependencies = [
        ('wooey', '0036_add-jsonfield'),
    ]

    operations = [
        migrations.RunPython(populate_default)
    ]

Convert iniital json field if possible in migration
Convert iniital json field if possible in migration

  from __future__ import unicode_literals
+ import json
  
  from django.db import migrations
  
  
  def populate_default(apps, schema_editor):
      ScriptParameter = apps.get_model('wooey', 'ScriptParameter')
      for obj in ScriptParameter.objects.all():
+         try:
+             obj.default = json.loads(obj._default)
+         except Exception:
-         obj.default = obj._default
+             obj.default = obj._default
          obj.save()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('wooey', '0036_add-jsonfield'),
      ]
  
      operations = [
          migrations.RunPython(populate_default)
      ]
  
Convert iniital json field if possible in migration
## Code Before:
from __future__ import unicode_literals

from django.db import migrations


def populate_default(apps, schema_editor):
    ScriptParameter = apps.get_model('wooey', 'ScriptParameter')
    for obj in ScriptParameter.objects.all():
        obj.default = obj._default
        obj.save()


class Migration(migrations.Migration):

    dependencies = [
        ('wooey', '0036_add-jsonfield'),
    ]

    operations = [
        migrations.RunPython(populate_default)
    ]

## Instruction:
Convert iniital json field if possible in migration
## Code After:
from __future__ import unicode_literals
import json

from django.db import migrations


def populate_default(apps, schema_editor):
    ScriptParameter = apps.get_model('wooey', 'ScriptParameter')
    for obj in ScriptParameter.objects.all():
        try:
            obj.default = json.loads(obj._default)
        except Exception:
            obj.default = obj._default
        obj.save()


class Migration(migrations.Migration):

    dependencies = [
        ('wooey', '0036_add-jsonfield'),
    ]

    operations = [
        migrations.RunPython(populate_default)
    ]
