Making Django forms.DateField show use local date format

前端 未结 4 659
死守一世寂寞
死守一世寂寞 2020-12-29 14:35

I\'m trying to find an easy way to build forms which show dates in the Australian format (dd/mm/yyyy). This was the only way I could find to do it. It seems like there sho

4条回答
  •  囚心锁ツ
    2020-12-29 15:07

    In my form I'me using:

    def today():
        from datetime import date
        return date.today().strftime("%d.%m.%Y")
    
    when = models.DateField(u'Когда', default=today)
    

提交回复
热议问题