How to store an integer leaded by zeros in django

后端 未结 2 1140
没有蜡笔的小新
没有蜡笔的小新 2020-12-17 20:49

I\'m trying to store a number in django that looks like this:

000001

My problem is that if I type this inside an IntegerField it gets conve

2条回答
  •  悲哀的现实
    2020-12-17 21:07

    Don't store it with the leading zeros. Format it on output instead:

    (in view: value = 1)
    {{ value|stringformat:"04d" }} # displays as 0001
    

提交回复
热议问题