0

I have a django secret key in a .env which is being read as a blank string part of the secret key is attached below

SECRET_KEY=|$u6qthu06zp|$q

at the point where the $ sign starts I keep getting the message

level=warning msg="The "u6qthu06zp" variable is not set. Defaulting to a blank string." level=warning msg="The "q" variable is not set. Defaulting to a blank string."

the settings file has

import os
import environ

PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)


env = environ.Env(DEBUG=(bool,False))

environ.Env.read_env(env_file=".env")

and in the final secret key is written

SECRET_KEY = env("SECRET_KEY")

however I am not being able to run the docker-compose build --remove-orphan as the SECRET_KEY is coming back as an empty string seemingly because the $ sign is causing some kind of failure. Any advice will be appreciated

The make file has

ifneq (,$(wildcard  ./ .env))
 include .env
 export
 ENV_FILE_PARAM = --env-file .env
endif

and I am trying to run

docker-compose up --build -d --remove-orphans
  • I don't know why the `makefile` label is here because you don't actually show anything related to makefiles here. But if you intend to say that `SECRET_KEY=|$u6qthu06zp|$q` is actually appearing in a makefile, then you have to escape the `$` in makefiles, as `$$`. – MadScientist Aug 16 '23 at 15:50
  • 1
    I believe you need to escape the dollar signs in the `.env` file, like so `SECRET_KEY=|\$u6qthu06zp|\$q` – John Gordon Aug 16 '23 at 16:07
  • John Gordon you were correct except the back space needed to be after the dollar signs – Juan Monster Aug 22 '23 at 20:03

0 Answers0