Saturday, February 26, 2022

[google-cloud-sql-discuss] KeyError: 'SECRET_KEY' on Secret Manager


I want to run a Django application on the App Engine flexible environment.
I follow the documentation step by step (https://cloud.google.com/python/django/flexible-environment).

For the Django sample app, on Cloud SQL I'm using PostgreSQL

I store the secret values (Django settings) in Secret Manager, (https://cloud.google.com/python/django/flexible-environment#store-secret-values-in-secret-manager)

Now with the backing services configured, I try to run the sample app on my computer (I mean the sample app provided by the documentation https://cloud.google.com/python/django/flexible-environment#clone_a_sample_app)

At step 4, "Run the Django migrations to set up your models and assets" when I run the  "python manage.py makemigrations" command I get a series of errors:

File "C:\Users\zzz\AppData\Local\Programs\Python\Python39\lib\site-packages\environ\environ.py", line 367, in get_value
    value = self.ENVIRON[var]
  File "C:\Users\zzz\AppData\Local\Programs\Python\Python39\lib\os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'SECRET_KEY'

During handling of the above exception, another exception occurred:
....
File "C:\Users\zzz\AppData\Local\Programs\Python\Python39\lib\site-packages\environ\environ.py", line 371, in get_value
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: Set the SECRET_KEY environment variable

What could be the cause? I followed the documentation step by step.

Of course, on the code samples I edited the db name, the db password, project ID, region, instance name, bucket name etc

Thank you!
Valdinia





--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/6b667fbf-d405-4e98-b95e-c07b59da9557n%40googlegroups.com.

No comments:

Post a Comment