新建的Django项目运行时报错
程序员文章站
2022-03-21 18:32:51
用Pycharm新建了一个Django项目,试图运行时报错,信息如下:"D:\Python\bin\runnerw64.exe" "D:\Python\Python 3.8.5\python.exe" D:/Python/WebStuManage/manage.py runserver 8000Traceback (most recent call last): File "D:/Python/WebStuManage/manage.py", line 22, in ...
用Pycharm新建了一个Django项目,试图运行时报错,信息如下:
"D:\Python\bin\runnerw64.exe" "D:\Python\Python 3.8.5\python.exe" D:/Python/WebStuManage/manage.py runserver 8000
Traceback (most recent call last):
File "D:/Python/WebStuManage/manage.py", line 22, in <module>
main()
File "D:/Python/WebStuManage/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "D:\Python\Python 3.8.5\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "D:\Python\Python 3.8.5\lib\site-packages\django\core\management\__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "D:\Python\Python 3.8.5\lib\site-packages\django\conf\__init__.py", line 83, in __getattr__
self._setup(name)
File "D:\Python\Python 3.8.5\lib\site-packages\django\conf\__init__.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "D:\Python\Python 3.8.5\lib\site-packages\django\conf\__init__.py", line 177, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "D:\Python\Python 3.8.5\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\Python\WebStuManage\WebStuManage\settings.py", line 57, in <module>
'DIRS': [os.path.join(BASE_DIR, 'templates')]
NameError: name 'os' is not defined
Process finished with exit code 1
事实上,归根结底时最后的NameError提示,只需在settings.py中加入
import os
即可。
本文地址:https://blog.csdn.net/qq_45853731/article/details/107891151
上一篇: 换个角度使用VUE过滤器
下一篇: 初识爬虫之安装准备篇
推荐阅读
-
django修改表数据结构后报错的解决办法
-
详解Django项目中模板标签及模板的继承与引用(网站中快速布置广告)
-
解决在vue项目中,发版之后,背景图片报错,路径不对的问题
-
简单介绍Python的Django框架的dj-scaffold项目
-
vue init webpack 建vue项目报错的解决方法
-
全面剖析Python的Django框架中的项目部署技巧第1/2页
-
用Vue-cli搭建的项目中引入css报错的原因分析
-
Idea跑的项目没问题将程序install成jar包运行报错空指针的问题
-
Android Studio更新到3.1以后旧项目报错的解决办法
-
python的web框架---Django项目