错误信息如下:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/conf/__init__.py", line 83, in __getattr__
self._setup(name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/conf/__init__.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/conf/__init__.py", line 177, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/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 "/Users/vito/Desktop/django_demo/student_management/student_management/settings.py", line 57, in <module>
'DIRS': [BASE_DIR+'templates',],
TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'
解决方法:将settings中的'DIRS': [BASE_DIR+'templates',],改为:
'DIRS': [BASE_DIR,'templates',],
关注我的微信公众号论程序员的自我修养回复Python获取海量Python教程!!