2
0

More than 1 year has passed since last update.

【解決】django.core.exceptions.ImproperlyConfigured: Requested setting SECRET_KEY, but settings are not configured のエラーが出た。

Last updated at Posted at 2021-09-24

django.core.exceptions.ImproperlyConfigured: Requested setting SECRET_KEY, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

というエラー文が出た。

エラー文に書いてあるようにsettingsファイルを指定してやる。
具体的にはrunserverコマンドに--settings=[メインのアプリケーション名].settingsを追加した。
docker使っているからこんなエラーが出たのかなと思った。よーわからんけどね。。。

docker-compose.yml
  web:
    container_name: django-docker
    platform: linux/x86_64
    build: .
    command: python3 manage.py runserver 0.0.0.0:8000 --settings=django_docker.settings
    # ↑ここに追加
    working_dir: /code
    ports:
      - 18000:8000
    volumes:
      - ./:/code
    depends_on:
      - db
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0