So I'm just starting out with Django and using it to store forex prices which are represented as 1.21242
, 1.20641
, etc...
model.py
from django.db import models
# Create your models here.
class ForexPrice(models.Model):
openPrice = models.DecimalField(max_digits=6, decimal_places=6)
highPrice = models.DecimalField(max_digits=6, decimal_places=6)
lowPrice = models.DecimalField(max_digits=6, decimal_places=6)
closePrice = models.DecimalField(max_digits=6, decimal_places=6)
My Question Is:
How do the max_digits and decimal_places attributes work? I'm using 6 for both fields assuming max_digits=6
will allow values to be stored up to 6 digits ie: 123456.000000 while decimal_palces=6
will support values up to 000000.123456.
Is this assumption correct or am I missing something?
Getting the following error when I save the record to the DB:
A field with precision 6, scale 6 must round to an absolute value less than 1.