Error in running a project regarding virtual environment and "DJANGO_SECRET_KEY" in VS code

Question:

I want to run a project from gitlab on my local machine. I cloned the project, created a virtual environment and activated it. When I want to run without debugging I got this error:

File "c:UsersMEDesktoptestz_toolsettings.py", line 28, in <module>
    SECRET_KEY = env.str('DJANGO_SECRET_KEY')
  File "c:UsersMEDesktoptestmyenvlibsite-packagesenvirons__init__.py", line 110, in method
    raise EnvError('Environment variable "{}" not set'.format(proxied_key or parsed_key))
environs.EnvError: Environment variable "DJANGO_SECRET_KEY" not set

The output of this project is a form, how can I solve this error to get the output?

Asked By: aida jbigloo

||

Answers:

There’s a good explanation here https://stackoverflow.com/a/47117966/20027268

basically it’s used for securing data in a django app, you can get around this for now by setting the DJANGO_SECRET_KEY environment variable to something random for now:

Windows: https://www.tutorialspoint.com/how-to-set-environment-variables-using-powershell

Mac: export [variable_name]=[variable_value]

Answered By: Luke Scales