Django Internationalisation Issues with number fields in European countries

I’ve been working on converting a very large Django project to support translations which has been going well until I hit an issue that had not come across before specifically around HTML input tags with of a number type and floating point values.What I’m finding is that everything works fine for countries that use a dot for a decimal point but in countries that use a comma whilst Django is converting the value in the forms to say 100,10 from 100.10 the HTML tag that’s generate is then invalid and the value does not render to the user resulting in empty forms.I’ve been testing using Chrome with the Sensors tool enable and switching between UK, USA and Gerrmany location and when I switch to Berlin (Locale db-DE) things break.To get around this I’m having to force all DecimalFields on the model into TextFields within the forms with a widget of:
widget=forms.TextInput(attrs={"inputmode": "decimal", "min": "0"})
So that a number input appears on mobile devices. I then have to overload the clean method on the model forms to reformat the string into the correct format based upon a function I wrote that looks for how many digits are after the decimal separator in order to determine if the , is a decimal or not. It’s not ideal and feels like it shouldn’t be needed especially when the docs state “Django’s formatting system is capable of displaying dates, times and numbers in templates using the format specified for the current locale. It also handles localized input in forms.

Translations work fine it just seems to be an issue between the data coming out of Django into form templates vs the browser rendering.

I thought it could be the sensors in chrome causing the data to come back in de-DE format and then the browser knowing that 'I’m in the UK but actual users based in both Germany and Italy have reported issues.

Other than setting the middleware to include “django.middleware.locale.LocaleMiddleware” and the following other settings in settings.py I didn’t think there was anything else I would need to go on either the form nor the template

`LANGUAGE_CODE = “en-gb”

TIME_ZONE = “UTC”

USE_I18N = True
LANGUAGES = [
(“en”, _(“English”)),
(“fr”, _(“French”)),
(“de”, _(“German”)),
(“it”, _(“Italian”)),
(“jp”, _(“Japanese”)),
(“es”, _(“Spanish”)),
(“es-AR”, _(“Spanish - Argentina”)),
]
LOCALE_PATHS = [
BASE_DIR / Path(“locale”),
]
LANGUAGE_COOKIE_NAME = “django_language”`

Has anyone else encountered this issue and knows where I’m going wrong? The only related bugs I’ can find are closed ones form Django 1.5 and earlier.

It seems to be behaving differently within Django Admin where the data is always reading the value as using the dot separator for number fields so it’s just on the websites frontend which is using {% load i18n %}.