• Skip to main content
  • Skip to primary sidebar

学習記録

.envファイル設定

2021年6月30日 by 河副 太智 Leave a Comment

設定の基本はこちらを参照

envファイル読み込み

1
2
3
4
5
6
7
8
9
10
11
#env設定
import environ
env = environ.Env(
    # set casting, default value
    DEBUG=(bool, False)
)
 
env.read_env('.env')
 
# False if not in os.environ
DEBUG = env('DEBUG')

settings.py設定

1
2
3
4
5
6
7
8
9
10
11
12
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')
 
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': env('DATABASE_NAME'),
        'USER': env('USER'),
        'PASSWORD': env('DATABASE_PASS'),
        'HOST': '',
        'PORT': '',
    }
}

.envファイル設定

1
2
3
4
EMAIL_HOST_PASSWORD=SG.xxxxxxxxxxxxxxJ30Ame4ORjxiM880j0eL_3rgU
DATABASE_PASS=xxxxxxx
DATABASE_NAME=xxxxxxx
USER=xxxxxx

イコール(=)の両側にスペースがあるとエラーになるのでぴったりくっつける。
ローカルからaws等にgitを使用せずにenvファイルを移動する際、googledriveで
別PCに転送すると以下のようンエラーが出る。
django.core.exceptions.ImproperlyConfigured: Set the EMAIL_HOST_PASSWORD environment variable

USBメモリでenvファイルの移動をすれば問題ない。

 

このエントリーをはてなブックマークに追加

Tweet
[`yahoo` not found]
このエントリーを Google ブックマーク に追加
LinkedIn にシェア
LINEで送る


Filed Under: Django

Reader Interactions

コメントを残す コメントをキャンセル

メールアドレスが公開されることはありません。 ※ が付いている欄は必須項目です

Primary Sidebar

カテゴリー

  • AWS
  • Bootstrap
  • Dash
  • Django
  • flask
  • GIT(sourcetree)
  • Plotly/Dash
  • VPS
  • その他tool
  • ブログ
  • プログラミング
    • Bokeh
    • css
    • HoloViews
    • Jupyter
    • Numpy
    • Pandas
    • PosgreSQL
    • Python 基本
    • python3
      • webアプリ
    • python3解説
    • scikit-learn
    • scipy
    • vps
    • Wordpress
    • グラフ
    • コマンド
    • スクレイピング
    • チートシート
    • データクレンジング
    • ブロックチェーン
    • 作成実績
    • 時系列分析
    • 機械学習
      • 分析手法
      • 教師有り
    • 異常値検知
    • 自然言語処理
  • 一太郎
  • 数学
    • sympy
      • 対数関数(log)
      • 累乗根(n乗根)
    • 暗号学

Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in