I have a problem with WSGI!
I got the error:
2025-02-08 15:00:31,821: Error running WSGI application
2025-02-08 15:00:31,822: NameError: name 'get_key' is not defined
2025-02-08 15:00:31,822: File "/var/www/akrabato_pythonanywhere_com_wsgi.py", line 25, in <module>
2025-02-08 15:00:31,822: application = get_wsgi_application()
2025-02-08 15:00:31,822:
2025-02-08 15:00:31,823: File "/home/akrabato/.virtualenvs/djangovet_env/lib/python3.10/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2025-02-08 15:00:31,823: django.setup(set_prefix=False)
2025-02-08 15:00:31,823:
2025-02-08 15:00:31,823: File "/home/akrabato/.virtualenvs/djangovet_env/lib/python3.10/site-packages/django/__init__.py", line 19, in setup
2025-02-08 15:00:31,823: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2025-02-08 15:00:31,824:
2025-02-08 15:00:31,824: File "/home/akrabato/.virtualenvs/djangovet_env/lib/python3.10/site-packages/django/conf/__init__.py", line 82, in __getattr__
2025-02-08 15:00:31,824: self._setup(name)
2025-02-08 15:00:31,824:
2025-02-08 15:00:31,824: File "/home/akrabato/.virtualenvs/djangovet_env/lib/python3.10/site-packages/django/conf/__init__.py", line 69, in _setup
2025-02-08 15:00:31,825: self._wrapped = Settings(settings_module)
2025-02-08 15:00:31,825:
2025-02-08 15:00:31,825: File "/home/akrabato/.virtualenvs/djangovet_env/lib/python3.10/site-packages/django/conf/__init__.py", line 170, in __init__
2025-02-08 15:00:31,825: mod = importlib.import_module(self.SETTINGS_MODULE)
2025-02-08 15:00:31,825:
2025-02-08 15:00:31,826: File "/home/akrabato/djangovet/djangovet/settings.py", line 94, in <module>
2025-02-08 15:00:31,826: 'USER': get_key("DBUSER"),
2025-02-08 15:00:31,826: ***************************************************
2025-02-08 15:00:31,826: If you're seeing an import error and don't know why,
2025-02-08 15:00:31,826: we have a dedicated help page to help you debug:
2025-02-08 15:00:31,827: https://help.pythonanywhere.com/pages/DebuggingImportError/
But I have a defiinition of getKey function in line 25:
def getKey(setting, project_keys=project_keys):
try:
return project_keys[setting]
except KeyError:
errorMessage = "Set the {} env var".format(setting)
raise ImproperlyConfigured(errorMessage)
So, I don’t understand why I got this error in line 94:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'USER': get_key("DBUSER"),
'PASSWORD': get_key("DBPASSWORD"),
'HOST': get_key("DBHOST"),
'PORT': '5432',
}
}
Could you, please, provide full settings.py file!