运行 这个 django 项目但是它在 manage.py 中向我显示了这个错误
running this django project but its showing me this error in manage.py
这是在 运行 可搜索下拉列表的 django 项目时向我显示的错误。我完全按照 youtube 视频中提到的那样做了,但这些都是它向我展示的错误
File "manage.py", line 23, in <module>
main()
File "manage.py", line 19, in main
execute_from_command_line(sys.argv)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "C:\ProgramData\Anaconda3\lib\site-packages\django\conf\__init__.py", line 83, in __getattr__
self._setup(name)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\conf\__init__.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\conf\__init__.py", line 177, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\mahima\Downloads\dropdown\ddl\ddl\settings.py", line 58, in <module>
'DIRS': [os.path.join(BASE_DIR,'templates')],
NameError: name 'os' is not defined
这是我的 manage.py 文件。我有 mysql installed.Can 谁能告诉我如何解决所有这些错误?我是新人
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ddl.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
尝试在文件顶部添加 C:\Users\mahima\Downloads\dropdown\ddl\ddl\settings.py
import os
看起来你错过了模块的导入
这是在 运行 可搜索下拉列表的 django 项目时向我显示的错误。我完全按照 youtube 视频中提到的那样做了,但这些都是它向我展示的错误
File "manage.py", line 23, in <module>
main()
File "manage.py", line 19, in main
execute_from_command_line(sys.argv)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "C:\ProgramData\Anaconda3\lib\site-packages\django\conf\__init__.py", line 83, in __getattr__
self._setup(name)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\conf\__init__.py", line 70, in _setup
self._wrapped = Settings(settings_module)
File "C:\ProgramData\Anaconda3\lib\site-packages\django\conf\__init__.py", line 177, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\ProgramData\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\mahima\Downloads\dropdown\ddl\ddl\settings.py", line 58, in <module>
'DIRS': [os.path.join(BASE_DIR,'templates')],
NameError: name 'os' is not defined
这是我的 manage.py 文件。我有 mysql installed.Can 谁能告诉我如何解决所有这些错误?我是新人
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ddl.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
尝试在文件顶部添加 C:\Users\mahima\Downloads\dropdown\ddl\ddl\settings.py
import os
看起来你错过了模块的导入