1

我试图让表单接受带有不同小数分隔符的小数,但它似乎不起作用。

USE_L10N = True在设置和localize=True表单字段中有,但它只接受我正在测试的两台机器上的句点(应该在我的辅助机器上接受逗号)

有什么我想念的吗?

我使用的是 Windows,但在生成翻译文件/语言环境文件夹方面我没有做任何事情。

4

1 回答 1

0

It works for me with this form:

class InvoiceItemForm(forms.ModelForm):
    price = forms.CharField(max_length=10, min_length=1, localize=True)
    quantity = forms.CharField(max_length=10, min_length=1, localize=True)

Also on settings:

LANGUAGE_CODE = 'en'
USE_I18N = True
USE_L10N = True

And check the "Accept-Language" that your browser is sending to the server. Mine is "en-us,en;q=0.8,es-es;q=0.5,es;q=0.3" and shows format in "en".

于 2013-04-27T21:51:33.477 回答