One of my model's field looks like this:
total_amount = models.DecimalField(max_digits=20,decimal_places=4,default=Decimal('0.0000'))
but when I run this command python manage.py syncdb
, it shows this error:
NameError: name 'Decimal' is not defined
I have imported from django.db import models
, do I need to import any other thing too?
Please Help!
You need to import Decimal.
from decimal import Decimal
total_amount = models.DecimalField(max_digits=20, decimal_places=4, default=0.0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With