Localization with thousand separator makes foreign key id invalid in forms

107 views
Skip to first unread message

Alti

unread,
May 11, 2017, 11:39:41 AM5/11/17
to Django users
Hello, 

With localization and thousand separator active, my foreign keys ids are rendered with a thousand separator in django forms and give me an invalid field during validation.

in settings.py:
USE_L10N = True
USE_THOUSAND_SEPARATOR = True

example  : 
<option value="17 943" selected="">Company something something</option> with the french localization

For now i just override the template django/forms/widgets/select_option.html with the safe filter :
<option value="{{ widget.value|safe }}"{% include "django/forms/widgets/attrs.html" %}>{{ widget.label }}</option>

I think it would be nicer to have the safe filter in the default template from django repository.

Now i file it here to see if people consider it as a bug or if this behavior is considered as normal and if others get this problem as well, before filing a ticket on djangoproject.com.

Regards, 

Thomas.

Melvyn Sopacua

unread,
May 11, 2017, 12:21:02 PM5/11/17
to django...@googlegroups.com

On Thursday 11 May 2017 08:39:41 Alti wrote:

 

> With localization and thousand separator active, my foreign keys ids

> are rendered with a thousand separator in django forms and give me an

> invalid field during validation.

 

Is this a regression? Same code works in 1.10?

 

--

Melvyn Sopacua

Simon Charette

unread,
May 11, 2017, 12:30:52 PM5/11/17
to Django users
Hello Thomas,

Probably caused by #28075 [0], fixed in 1.11.1.

Cheers,
Simon

Alti

unread,
May 12, 2017, 6:40:20 AM5/12/17
to Django users
Hello Simon,

I confirm, updated the project to 1.11.1 and it is solved.

Thanks for taking the time to check.

Thomas.
Reply all
Reply to author
Forward
0 new messages