[Answered ]-Django โ€“ Invalid literal for int() with base 10 python django

2๐Ÿ‘

โœ…

If the primary key of the related model is an int (ids are int by default), the ForeignKey column is also an int.

What you can do now is to edit the generated migration file (yourapp/migrations/000x_auto_xyz.py) and delete the part that tries to set the default value. For example, if your migration file looks like this:

class Migration(migrations.Migration):

    dependencies = [
    ...
    ]

    operations = [
        migrations.CreateModel(
            name='Application',
            fields=[
                ...
                ('myforeignkey', models.ForeignKey(to='otherapp.OtherModel', default='t')),
            ],
            ...
    ]

then just remove the , default='t' part and re-run manage.py migrate.

๐Ÿ‘คSelcuk

Leave a comment