PyCharm can#39;t find the right paths if I open a directory that is not the Django root(如果我打开一个不是 Django 根目录的目录,PyCharm 找不到正确的路径)
问题描述
我们的项目通常是结构化的:
Our projects are usually structured:
/project-name
/src
/django-project-name
etc..
readme.md
requirements.txt
如果我打开 /project-name 而不是 /django-project-name PyCharm 强调我的导入说他们找不到,它会尝试将导入引用为 src.django-project-name.app_name.models.Thing 运行 Django 时实际上找不到.
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.
我怎样才能让它像我挂载 /djang-project-name 时一样工作?
How can I get it to work the same as when I mount /djang-project-name where it gets these things right?
推荐答案
我通过转到 File -> 修复了它首选项->项目结构在树中选择/django-project-name,点击sources添加.
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 找不到正确的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如果我打开一个不是 Django 根目录的目录,PyCha
基础教程推荐
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
