I changed one of my CharField in models.py::
models.CharField(max_length=128, blank=True)
into IntegerField -->
models.IntegerField(default=0)
I have data for that field, mainly empty strings("") or integer as strings(eg: "10").
So I would like to convert these strings to integer while migrate. eg::
if blank string("") convert to 0, else convert to integer.
How can i achive that while i do ./manage.py migrate command?
here is the migration file created using ./manage.py makemigrations::
# Generated by Django 2.1.2 on 2018-10-25 04:57
from django.db import migrations, models
class Migration(migrations.Migration):
    dependencies = [
        ('dashboard', '0002_auto_20181024_1544'),
    ]
    operations = [
        migrations.AlterField(
            model_name='aclpermissions',
            name='ordering',
            field=models.IntegerField(default=0),
        ),
        migrations.AlterField(
            model_name='submenus',
            name='ordering',
            field=models.IntegerField(default=0),
        ),
        migrations.AlterField(
            model_name='subsubmenus',
            name='ordering',
            field=models.IntegerField(default=0),
        ),
    ]
When i run ./manage.py migrate i got error ::
psycopg2.DataError: invalid input syntax for integer: ""
because there are fields with empty strings "".
So I want to convert empty strings ("") to 0.
 
     
     
     
    