cookiecutter django로 새 프로젝트를 만들었습니다. 환경 변수 DJANGO_READ_DOT_ENV_FILE = True (또한 False로 설정하면 .env 파일이 btw로 읽혀집니다. Python에서는 True 환경 변수가 bool이 아닌 문자열이라고 가정합니다.).django runserver .env 파일로 생산이 확인되었을 때 로컬 설정을 사용하여 시작
Loading : /home/bucket/src/b2b/.env
The .env file has been loaded. See common.py for more information
Loading : /home/bucket/src/b2b/.env
The .env file has been loaded. See common.py for more information
Performing system checks...
System check identified no issues (0 silenced).
February 14, 2017 - 20:20:55
Django version 1.10.5, using settings 'config.settings.local'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
에 따르면 : 나는
python manage.py runserver
나는 다음과 같은 출력을 얻을 실행하면
DJANGO_SETTINGS_MODULE=config.settings.production
다음은 .env 파일에서
다음 줄이 위의 서버 설정은 config.settings.local입니다.변수가 올바르며 .env 파일이로드되고 데이터베이스에 연결된다는 것을 알고 있습니다.
.env 파일에서 변수를로드하는 코드가 두 번 실행되는 것처럼 보입니다. 아래의 결과로 실행을 추적하기 위해 common.py와 local.py에 print 문을 몇 개 넣었습니다.
Loading : /home/bucket/src/b2b/.env
The .env file has been loaded. See common.py for more information
End of common.py <--
End of local.py <--
Loading : /home/bucket/src/b2b/.env
The .env file has been loaded. See common.py for more information
End of common.py <--
End of local.py <--
Performing system checks...
System check identified no issues (0 silenced).
February 14, 2017 - 20:22:40
Django version 1.10.5, using settings 'config.settings.local'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
이 동작에 대한 도움이나 설명을 제공해 주시면 감사하겠습니다.
CookiCutter에서 몇 가지 문제가 발생할 수 있습니다. - 장고. [Issue 1039] (https://github.com/pydanny/cookiecutter-django/issues/1039)는'DJANGO_READ_DOT_ENV_FILE = False' 일 때 환경을 읽는 문제를 수정해야합니다. [이 커밋] (https://github.com/pydanny/cookiecutter-django/commit/3cd57880e0bfa3d48ecd338fabe7f74e71800f01) 환경을 두 번 읽은 문제가 해결 될 수 있습니다. – Alasdair
중복 env 호출을 제거했으나 여전히 두 번 호출 중입니다. 내가 이슈 1039를 제출 한 사람이었습니다 :-) –
runserver를 실행할 때만 설정 파일이 두 번로드됩니다. 마이그레이션, 쉘 또는 다른 명령을 수행하면 한 번만 실행됩니다. –