pylint 导入失败
我正在使用 pylint 测试我的项目,目前在将内部应用程序导入项目时出现致命错误。
根据 pylint 的说法,导入应该类似于 from
与我目前拥有的相反: from
我的问题是,当我使用推荐的样式时,项目无法找到/导入应用程序。我在这里缺少什么?
I'm testing my project using pylint and currently getting fatal error when importing the internal apps into the project using.
According to pylint, the import should be something like from <appname>.models import ...
as opposed to what I currently have: from <projectname>.<appname>.models import
My problem is that when I use the recommended style, the project can't find/import the app. What am I missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的应用程序不在 python 路径中。
似乎您有一个应用程序文件夹,例如
apps/registration
、apps/contact_form
等,并且您的 manage.py 位于该文件夹顶部的文件夹中,其中包含只是项目文件夹。manage.py
通过在启动服务器之前将所有应用程序放入 python 路径中来实现一些“魔法”。如果您有自定义文件夹结构,则应编辑
manage.py
以将自定义应用程序文件夹包含在 python 路径中,最好作为 python 路径的第一个元素。Your apps are not in the python path.
Seems like you have a folder for apps, like
apps/registration
,apps/contact_form
etc. and your manage.py is in the folder on top of that one, which has just the project folder.manage.py
does some "magic" by putting all the apps into the python path before starting the server.If you have custom folder structure, you should edit the
manage.py
to include your custom apps folder in the python path, preferably as the first element of the python path.