简体   繁体   English

Django 说 SECRET_KEY 不能为空

[英]Django says SECRET_KEY must not be empty

I imported a Django project from a repo, and when I try to make the migrations with python manage.py makemigrations , I get the following exception:我从 repo 导入了一个 Django 项目,当我尝试使用python manage.py makemigrations进行迁移时,出现以下异常:

File "C:\Users\Iván\AppData\Local\Programs\Python\Python36\Lib\site-packages\django\conf\__init__.py", line 161, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

After looking online, I read that adding from base import * to __init__.py could solve it, but it just sends a different error:在网上查看后,我读到添加from base import *__init__.py可以解决它,但它只是发送一个不同的错误:

    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  File "C:\Users\Iván\AppData\Local\Programs\Python\Python36\Lib\site-packages\django\conf\urls\static.py", line 22, in static
    raise ImproperlyConfigured("Empty static prefix not permitted")
django.core.exceptions.ImproperlyConfigured: Empty static prefix not permitted

My 'base.py' settings do have SECRET_KEY = 'my_key_value' , and my 'local.py' settings first line is from.base import * , and it doesn't override the SECRET_KEY, so I don't know why it says the SECRET_KEY is empty.我的 'base.py' 设置确实有SECRET_KEY = 'my_key_value' ,而我的 'local.py' 设置第一行是from.base import * ,它没有覆盖 SECRET_KEY,所以我不知道为什么它说SECRET_KEY 为空。 I do not see any other settings through the project, so I don't know where else to look, I'm new to django, so I'm a bit lost here and have been stuck for a few days.我没有通过项目看到任何其他设置,所以我不知道还能在哪里看,我是 django 的新手,所以我在这里有点迷茫,已经被卡住了几天。

In my 'wsgi.py' file, as well, it includes the line在我的“wsgi.py”文件中,它也包含以下行

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'quiniela.settings')

And in 'quiniela.settings' I have the 'init.py', 'base.py' and 'local.py'在“quiniela.settings”中,我有“init.py”、“base.py”和“local.py”

我通过在我的 manage.py 文件os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'quiniela.settings.local')更改为os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'quiniela.settings')来修复它,但仅在那里,不在 wsgi.py 中或更改任何其他内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django:即使SECRET_KEY设置存在于设置中,它也不能为空 - Django: The SECRET_KEY setting must not be empty even if it exists in settings SECRET_KEY设置不能为空-django + pycharm - The SECRET_KEY setting must not be empty - django+pycharm Django ImproperlyConfigured-SECRET_KEY设置不得为空 - Django ImproperlyConfigured - The SECRET_KEY setting must not be empty 环境变量 Django:配置不当:SECRET_KEY 设置不能为空 - Environment Variables Django: ImproperlyConfigured: The SECRET_KEY setting must not be empty Django SECRET_KEY 设置不能为空 github 工作流程 - Django SECRET_KEY setting must not be empty with github workflow Django:配置不当:SECRET_KEY 设置不能为空 - Django: ImproperlyConfigured: The SECRET_KEY setting must not be empty PythonAnyWhere SECRET_KEY设置不能为空 - PythonAnyWhere The SECRET_KEY setting must not be empty SECRET_KEY设置不能为空 - SECRET_KEY setting must not be empty 收到错误:django.core.exceptions.ImproperlyConfigured:Django 中的 SECRET_KEY 设置不能为空 - getting error : django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty in django Python django:django.core.exceptions.ImproperlyConfigured:SECRET_KEY设置不得为空 - Python django : django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM