상세 컨텐츠

본문 제목

Set Global Variable using settings.py

Django

by BenzhaminKim 2020. 10. 29. 14:17

본문

You want to use environment variables, so I'm going to talk about how to use it.

First, you need to define the variable you want to use on settings.py

 

settings.py

Then, you set a variable on the file you want to use.

models.py

Here, by using getattr(), you can set the variable. If you don't havr the attribute inside the class, then the third parameter,which is 15 in this case, replace for the variable.

'Django' 카테고리의 다른 글

Django with Docker  (0) 2021.01.15
Relationship between URLS and VIEWS  (0) 2020.10.29
Django URL with View  (0) 2020.10.29
Django Architecture  (0) 2020.10.29

관련글 더보기

댓글 영역