4👍
✅
The field type FloatField
does not accept decimal_places
as an option, it’s a option for DecimalField
. You could try changing your FloatField by a DecimalField if it fit your needs.
0👍
I got the similar error below:
TypeError: init() got an unexpected keyword argument ‘max_digits’
Because I set max_digits=5
to BigIntegerField(), IntegerField(), SmallIntegerField(), PositiveBigIntegerField(), PositiveIntegerField() and PositiveSmallIntegerField() as shown below:
class MyModel(models.Model):
field_1 = models.BigIntegerField(max_digits=5) # Here
field_2 = models.IntegerField(max_digits=5) # Here
field_3 = models.SmallIntegerField(max_digits=5) # Here
field_4 = models.PositiveBigIntegerField(max_digits=5) # Here
field_5 = models.PositiveIntegerField(max_digits=5) # Here
field_6 = models.PositiveSmallIntegerField(max_digits=5) # Here
So, I replace them with DecimalField as shown below, then the error above was solved:
class MyModel(models.Model):
field = models.DecimalField(max_digits=5, decimal_places=2)
- [Django]-Celery Async Tasks and Periodic Tasks together
- [Django]-Django creating object from POST
- [Django]-Running Django Custom Management Command – Path Issues
Source:stackexchange.com