DETAIL: A field with precision 2, scale 2 must round to an absolute value less than 1.
I am trying to deploy a Django app to Heroku. My Django application uses Sqlite3 and it works perfectly on my system. If you click 'like' on product it will update the ratings parameter by 1.
Here is the snippet of the Product model
class Product(models.Model):
image = models.CharField( max_length= 500, blank = True, help_text= 'Image link' )
title = models.CharField( max_length= 200)
description = models.TextField(blank = True)
price = models.DecimalField(max_digits= 10, decimal_places= 2, blank = True, )
ratings = models.DecimalField(max_digits=10, decimal_places=2, blank= True, default = 0)
Before clicking 'like' the ratings on the product is 4
After clicking 'like' the ratings increases to 5 without any error Result
This is how I'm updating the ratings:
if request.method == 'POST':
obj = Product.objects.get(id = i)
obj.ratings += Decimal(1)
obj.save()
However, after deploying to Heroku, when i click 'like' I get this error.
DataError at /home/1/ numeric field overflow
DETAIL: A field with precision 2, scale 2 must round to an absolute value less than 1.
(/home/1/ is the route)
I don't get why
precision 2, scale 2?
I get that heroku might be using PostgreSQL as it says on the error page
But my max_digit is 10 and decimal place is 2. Before I also started with max_digits= 1000. There was still a data error. How do I resolve this error?