I have a model with a field having choices in it as given below. I am messing with the DecimalField somehow. And i cannot pass values like 1.7 or 2.6. But it is accepting 1.0 and 2.0 . Please let me know what am I doing wrong.
class Trip(models.Model):
ACE = 1.00
Dosth = 1.70
TEN = 2.00
FORTEEN = 2.30
SEVENTEEN = 2.60
NINETEEN = 2.90
TWENTY = 3.10
TWENTYTWO = 3.10
VEH_CHOICES = (
(ACE, 'ACE'),
(Dosth, 'Dosth'),
(TEN, '10.5FT'),
(FORTEEN, '14FT'),
(SEVENTEEN, '17FT'),
(NINETEEN, '19FT'),
(TWENTY, '20FT'),
(TWENTYTWO, '22FT'),
)
ftype = models.DecimalField(null = True, blank = True, verbose_name = "Vehicle Type", decimal_places = 2, max_digits = 5, choices = VEH_CHOICES)
You need to change field
DecimalFieldtoFloatFieldi give the new model with changesee diff of
DecimalFieldandFloatFieldUpdate this code to your code see it work. if it's work perfect or not let me know