Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Decimal separator is incorrectly managed by the browsable API #3139

@dispiste

Description

@dispiste

I have a model containing FloatField field:

coste = models.FloatField(null=True, blank=True)

and I have built a browsable API for the model using djangorestframework.

In the put form of the browsable API, the coste field is automatically formatted using a comma separator (so 3.0 is shown in the form as 3,0). I guess django or djangorestframework are formatting it according to my system locale.

However, if the form is submitted an error because of the number formatting:
HTTP 400 Bad Request

{
    "coste": [
        "Se requiere un número válido. [means: A valid number is required]"
    ]
}

I am aware that djangorestframework does not support localized decimal fields (according to #2897), but I would expect that it is able to create a non-localized field which correctly works on a localized environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions