我是 Django 的新手,刚开始使用新项目。
我在尝试传入应用程序 URL 时遇到了这个问题。
导入错误:无法从“first_project”导入名称“first_app” (E:\Project\DjangoProject\first_project\first_project_init_.py)
答案 0 :(得分:0)
尝试在 settings.py
中设置路径,如下所示:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, BASE_DIR)
sys.path.insert(0, os.path.join(BASE_DIR, 'backend/apps'))
sys.path.insert(0, os.path.join(BASE_DIR, 'backend/extra_apps'))