开发者

Localization don't work on a ModelForm in Django

开发者 https://www.devze.com 2023-01-14 03:44 出处:网络
def Person开发者_运维知识库(models.Model) name = models.CharField(max_length=50) birth_date = models.DateField()
def Person开发者_运维知识库(models.Model)
       name = models.CharField(max_length=50)
       birth_date = models.DateField()

and I have this form

def PersonForm(forms.ModelForm)

   class Meta:
      model = Person

I have to localize the project to spanish (es), and add a customized format module (FORMAT_MODULE_PATH) to set DATE_FORMAT = 'd/m/Y'. Everything works fine if I only show dates in the template, but when the form is diplayed with data from the database, the input control show the date as Y-m-d

How can I fix that?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号