Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django.db.utils.DataError: numeric field overflow - django

I am trying migrate using django but I get this error and I have no idea what to do to fix it.

I have google the error message but all it was talking about postgres.

I have this in my model

budget = models.DecimalField(max_digits=10, decimal_places=2, null=True, blank=True)
# I used to have this though
budget = models.IntegerField(null=True, blank=True)

I was using this command python manage.py makemigrations which generates the alter table fine but when I run the migrate python manage.py migrate this error would pop up.

Can someone please give me a hand?

Thanks in advance.

like image 468
Tsuna Avatar asked Oct 31 '25 12:10

Tsuna


1 Answers

The error message indicates that you have existing numbers longer than 8 digits (10-2) in your table. You might try modifying the offending rows if possible, or increase the max_digits to allow larger numbers.

like image 121
Selcuk Avatar answered Nov 03 '25 03:11

Selcuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!