My amount column attributes are set to max_digits = 13, decimal_places = 7 because you could technically have something like 10000.0000001 bitcoin.
When I try to enter and submit just 0.1 Bitcoin on my form I get the error:
Ensure that there are no more than 3 digits before the decimal point.
This isn't working as expected: 0.1 is not more than 3 digits, and even if it was I should still be able to set more than 3 digits.. What is happening here?
models.py
class Transactions(models.Model):
user = models.ForeignKey(User, on_delete = models.CASCADE)
coin = models.CharField(max_length = 64)
buysell = models.CharField(default = 'buy', max_length = 4)
amount = models.DecimalField(max_digits = 13, decimal_places = 7)
trade_price = models.DecimalField(max_digits = 5, decimal_places = 2)
trade_date = models.DateTimeField(auto_now = True)
forms.py
class TransactionForm(forms.ModelForm):
CHOICES = ((1, 'Buy'), (2, 'Sell'),)
coin = forms.ModelChoiceField(queryset = Coin.objects.all())
buysell = forms.ChoiceField(choices = CHOICES)
field_order = ['buysell', 'coin', 'amount', 'trade_price']
class Meta:
model = Transactions
fields = {'buysell', 'coin', 'amount', 'trade_price'}
number = round(0.1, 7)
. – Eucharis0.1
. Can you confirm the by checking the request data. It seems like there is something more being sent – Inbound