[django] convert integer to string

2016. 10. 19. 18:36프로그래밍/Python & dJango

1. 장고에서 integer형을 string으로 변환이 필요할 때 stringformat을 사용하면된다.


  사용법은 아래와 같다.


   {{ value | stringformat:"i" }}


  위의 코드를 설명하면


 1. value > 해당 값

 2. stringformat > tag

 3. "i" : format ( i  = integer)

 


3번의 형식은 아래의 url에서 포맷을 확인할 수 있다.

https://docs.python.org/3/library/stdtypes.html#old-string-formatting 

 

'프로그래밍 > Python & dJango' 카테고리의 다른 글

[django] 리스트 순번  (0) 2016.10.23
[Python] 집합 (set)  (0) 2016.10.19
[dJango] Q expression  (0) 2016.10.19
[Python] closure  (0) 2016.10.07
Python 환경변수 가져오기.  (0) 2016.10.05