程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

About raising improverconfigured (the secret_key setting must not be empty.) personal solution in Django project

編輯:Python

Running django Project time , There is raise ImproperlyConfigured(“The SECRET_KEY setting must not be empty.”)https://img-bsetting must not be empty.")]django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty. error , This literally means that there is no SECRET_KEY Set up , The error is reported as shown in the figure below :

First, this command is settings.py In file , The graph is as follows ,

However , When I look for solutions on the Internet , There is no solution to the problem that the error message still appears when this command is available , Here I give my final solution .

Because I do have this SECRET_KEY, So it's not this mistake , For those who do not have this, please find a solution online , You can add one to try . Next , Because it is not the problem that does not exist , So it could be manage.py When executing a command , Can't find settings.py file , So I think there is no such SECRET_KEY The result is an empty error , Found by inspection , My configuration is as follows :

Especially here .dev, This .dev I created a new one settings.py The file name and path have been reset , The project tree is as follows :

therefore , One reason is that the original settings.py After the path and name of the file , Not in time manage.py Document and asgi.py as well as usgi.py Synchronize new... In the file settings.py( I am here dev.py) The path and name of , Cause not found settings In this SECRET_KEY command . Of course , This is still a reason , Generally speaking, here we go , Resetting the correct path and name will successfully see the small rocket .

Write here , It's not over yet , Because my problem is not in the above two cases , The reasons are as follows :



When you click the next run button, when you select a different execution method , It will produce different results , One is running successfully , One is the mistake at the beginning The SECRET_KEY setting must not be empty, Here, just set it to manage.py If you start, you won't report an error .

in general , The reason for this problem is manage.py The document was not found settings.py The correct path or my wrong startup mode is not from manage function


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved