[Django]-Getting a ValueError: invalid literal for int() with base 10: '' error and don't know why

5👍

The int() function is throwing an exception because you are trying to convert something that is not a number.

I suggest that you might consider using debugging print statements to find out what plan’s and fiid’s are initally and how they change.

Another thing you can do is wrap the call to int() using try/catch

val='a'
try:
    int_val = int(val)
except ValueError:
    print("Failure w/ value " + val)

3👍

Somewhere in that chain of calls, you’re passing an empty string which the code is then trying to convert to an integer. Log your input at the time to track it down.

0👍

Suggest you look at the values of plan and fiid, because either plan or fiid is not set to the value that you think.

0👍

For me, I had to delete the migration folder and follow the steps in the top answer in this link and then re-run the migrations, and then the error went away and it worked.

Leave a comment