[SOLVED] Error in running a project regarding virtual environment and “DJANGO_SECRET_KEY” in VS code

Issue

This Content is from Stack Overflow. Question asked by aida jbigloo

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
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?



Solution

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]


This Question was asked in StackOverflow by aida jbigloo and Answered by Luke Scales It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?