django-import-export icon indicating copy to clipboard operation
django-import-export copied to clipboard

Decimal field gets overwritten by big decimal number

Open Y0d4l3 opened this issue 3 years ago • 6 comments

grafik

Y0d4l3 avatar Apr 19 '22 12:04 Y0d4l3

The number in the xlsx file is 1803,60

Y0d4l3 avatar Apr 19 '22 12:04 Y0d4l3

  • What type is the underlying model field?
  • Have you declared this field in your resource? If so, what widget type have you used (if any)?
  • The value is definitely 1803,60 ? (I get decimal.ConversionSyntax when trying to import this value)
  • What version of django-import-export / django are you using?

If you could include steps to reproduce in the test app that would be very helpful.

matthewhegarty avatar Apr 19 '22 15:04 matthewhegarty

I tried importing an XLSX field (Book "price" ) with a value of 1803.60 (I set the format to '0.00'). On, import the confirm screen implies that the trailing '0' will be lost on import which seems incorrect, because the value has not changed:

import1

matthewhegarty avatar Apr 19 '22 15:04 matthewhegarty

mode field: raw_requirement = models.DecimalField( verbose_name="Rohbedarf", max_digits=8, decimal_places=2, blank=True, null=True ) resource field: raw_requirement = fields.Field(column_name="Rohbedarf", attribute="raw_requirement") actual value in xlsx file: 1803,60 (cell formated as number) version of django / django-import-export: 4.0.2 / 2.8.0

Y0d4l3 avatar Apr 19 '22 17:04 Y0d4l3

Can you confirm that when it is imported to the db the value is correct? (you have decimal_places set to 2)?

matthewhegarty avatar Apr 20 '22 13:04 matthewhegarty

Yes the value from the xlsx file gets saved correctly to the db. Apparently it is only wrong while importing.

Y0d4l3 avatar Apr 20 '22 20:04 Y0d4l3