I used dotenv module installed with pip On Wed, 2 Mar 2022, 04:43 Adeyemi Deji, <adeyemide...@gmail.com> wrote:
> I also get this error anytime I deploy. It works on developments mode. I > suspect the error coming as a result of adding .env to .gitignore, which > doesn't reflect on GitHub and heroku doesn't have access to .env file. Pls > how do I sort this out? > > Thanks in advance for your help > > On Wed, 2 Mar 2022, 04:25 Mike Dewhirst, <mi...@dewhirst.com.au> wrote: > >> On 2/03/2022 9:00 am, Dev femibadmus wrote: >> >> Do u create the variable SECRET_KEY if no copy ur secret_key e.g >> "hdFgBv&$..." and create variable SECRET_KEY in ur env which could be or is >> ur hosting platform and give the value as ur secret_key >> >> On Sun, Feb 27, 2022, 21:19 Valdinia - Office <off...@valdinia.com> >> wrote: >> >>> On W10 I defined an environment variable: SECRET_KEY >>> In shell I can read the key: >>> >>> *>>> import os* >>> *>>> os.environ.get('SECRET_KEY')* >>> 'mysecretkey...' >>> >>> But when I'm doing the same thing in *settings.py* I get: >>> >>> \lib\site-packages\django\conf\__init__.py", line 90, in __getattr__ >>> raise >>> *ImproperlyConfigured("The SECRET_KEY setting must not be empty.") >>> django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must >>> not be empty.* >>> >>> I found all sorts of solutions, but none works for my app. What should I >>> do? >>> >> >> SECRET_KEY belongs in settings.py as a string >> >> Therefore, if you wish to avoid putting it in there directly (as we all >> do) you must call a function which returns a string. >> >> SECRET_KEY = get_secret_key() >> >> ... where you write get_secret_key() to pull it from the environment or a >> file somewhere which is not in your repository. >> >> In my case, I wrote get_creds() as a general purpose retriever of >> credentials and other bits and pieces which don't belong in the repository >> and/or change between servers, eg., staging vs production vs development >> etc. I keep those credentials in separate files in a standard location on >> every server. >> >> That is only suitable for servers I control. >> >> Cheers >> >> Mike >> >> >> >> >> >>> Thank you! >>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/4afcfd9b-da0f-472e-b5d7-6339088bc4f6n%40googlegroups.com >>> <https://groups.google.com/d/msgid/django-users/4afcfd9b-da0f-472e-b5d7-6339088bc4f6n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAD9bWYyaM2pfg_dvyxk_-UtAqOSi7viT51mX4OxwomFW9sU7Bg%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAD9bWYyaM2pfg_dvyxk_-UtAqOSi7viT51mX4OxwomFW9sU7Bg%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> >> >> -- >> Signed email is an absolute defence against phishing. This email has >> been signed with my private key. If you import my public key you can >> automatically decrypt my signature and be sure it came from me. Just >> ask and I'll send it to you. Your email software can handle signing. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/3b40c474-72c3-ced9-ecb7-fd1348845d00%40dewhirst.com.au >> <https://groups.google.com/d/msgid/django-users/3b40c474-72c3-ced9-ecb7-fd1348845d00%40dewhirst.com.au?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEO1Grpje48552nNfo%2BfhMrP3bXiRchimBtzUQWac1Ow%2BtoJiw%40mail.gmail.com.