이거 중요함.
체크안하고 render_template 함수에서 막 쓰면,
자꾸 선언되어 있지 않다고 오류가 막남... variable is undefined? 이런류의 에러, Exception 발생
들어올 수 도 있고 안 들어 올 수 도 있는 변수는 쓰기 전에 반드시 체크하고 사용하기 바람.
{% if variable is defined %}
variable is defined <- 쓰이기 전에 이렇게 definded 되어 있는지 확인하자.
{% else %}
variable is not defined
{% endif %}
www.shellhacks.com/jinja2-check-if-variable-empty-exists-defined-true/
Jinja2: Check If Variable - Empty | Exists | Defined | True - ShellHacks
How to check if Jinja2 variable is empty or not empty, exists or not exists, defined or not defined, if it is set to True or not.
www.shellhacks.com
BJ.

Paula Schmidt 님의 사진, 출처: Pexels
'IT > 파이썬' 카테고리의 다른 글
파이썬 pyside2 Qt designer QFrame 모양 속성 (0) | 2021.02.25 |
---|---|
파이썬 pyside2 QSplitter 한쪽은 fix 한쪽은 expand 되도록 수정하기 (0) | 2021.02.24 |
파이썬 bool 함수로 bool 으로 변환 내용정리 (0) | 2021.02.18 |
파이썬 Mongoengine 에서 Document 삭제 방법 flask (0) | 2021.02.17 |
파이썬 실행파일 만들기 - pyinstaller exe 실행파일 (0) | 2021.02.17 |