Question

I need to show a list like: 1,2,3,etc but show it like: 0001,0001,0003, etc

Exists a template filter in Django to to that?

Was it helpful?

Solution

Simplifying karthikr's answer, you can leverage one of the already provided django template tags to accomplish this:

{{ number|stringformat:"04d" }}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top