问题描述
我们的项目通常结构化:
/ project-name
/ src
/ django-项目名称
等..
readme.md
requirements.txt
如果我打开 / project-name
而不是 / django-project-name
PyCharm强调我的导入说他们找不到,并尝试引用导入为 src.django-project-name.app_name.models.Thing
,当您运行Django时无法实际找到。 / p>
我如何让它的工作与当我挂载 / djang-project-name
的地方一样事情正确吗?
我通过转到文件 - >偏好 - >项目结构
在树中选择 / django-project-name
,然后点击来源
添加它。
Our projects are usually structured:
/project-name
/src
/django-project-name
etc..
readme.md
requirements.txt
If I open /project-name
instead of /django-project-name
PyCharm underlines my imports saying they can't find and it tries to reference imports as src.django-project-name.app_name.models.Thing
which can't actually be found when you run Django.
How can I get it to work the same as when I mount /djang-project-name
where it gets these things right?
I fixed it by going to File -> Preferences -> Project Structure
selecting the /django-project-name
in the tree and clicking sources
to add it.
这篇关于如果我打开不是Django根目录,PyCharm找不到正确的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!