Monday, February 28, 2022

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

Hello, 

The documentation you followed guides towards setting up authentication in a Flexible environment. You need to run the app locally, so you should follow Run the app on your local computer

This discussion group is oriented more towards general opinions, trends, and issues of general nature touching the App Engine. For coding and program architecture, as well as setting up local authentication, you may be better served in dedicated forums such as stackoverflow, where experienced programmers are within reach and ready to help. 

On Sunday, 27 February 2022 at 13:02:55 UTC-5 Valdinia - Office wrote:

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/e4afe0ce-0737-4374-ac42-985ff78cc35an%40googlegroups.com.

No comments:

Post a Comment