biuubi 2020-02-09 13:49 采纳率: 0%
浏览 741

pycham中django项目中导入自定义模块报错

从进行数据迁移的时候,报的错。
从comment/models.py 导入blog/models.py中的Post类。刚接触这个,上网查了整不懂。。。图片说明图片说明图片说明
查的一般都说工作目录下搜不到这个目录,求大神告知

下面是我的报错
(venv) C:\Users\hty11\PycharmProjects\typeidea\typeidea>python manage.py makemigrations
C:\Users\hty11\PycharmProjects\typeidea\typeidea
C:\Users\hty11\PycharmProjects\typeidea
C:\Users\hty11\AppData\Local\Programs\Python\Python38-32\python38.zip
C:\Users\hty11\AppData\Local\Programs\Python\Python38-32\DLLs
C:\Users\hty11\AppData\Local\Programs\Python\Python38-32\lib
C:\Users\hty11\AppData\Local\Programs\Python\Python38-32
C:\Users\hty11\PycharmProjects\typeidea\venv
C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages
C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg
C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages\pip-19.0.3-py3.8.egg
C:\Users\hty11\PycharmProjects\typeidea\typeidea\blog\models.py
Traceback (most recent call last):
File "manage.py", line 24, in
main()
File "manage.py", line 20, in main
execute_from_command_line(sys.argv)
File "C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages\django\core\management__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages\django\core\management__init__.py", line 357, in execute
django.setup()
File "C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages\django__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\hty11\AppData\Local\Programs\Python\Python38-32\lib\importlib__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in _call_with_frames_removed
File "C:\Users\hty11\PycharmProjects\typeidea\typeidea\comment\models.py", line 7, in
from typeidea.blog.models import Post
ModuleNotFoundError: No module named 'typeidea.blog'

图片说明

C:\Users\hty11\PycharmProjects\typeidea\typeidea
C:\Users\hty11\PycharmProjects\typeidea
C:\Users\hty11\AppData\Local\Programs\Python\Python38-32\python38.zip
C:\Users\hty11\AppData\Local\Programs\Python\Python38-32\DLLs
C:\Users\hty11\AppData\Local\Programs\Python\Python38-32\lib
C:\Users\hty11\AppData\Local\Programs\Python\Python38-32
C:\Users\hty11\PycharmProjects\typeidea\venv
C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages
C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages\setuptools-40.8.0-py3.8.egg
C:\Users\hty11\PycharmProjects\typeidea\venv\lib\site-packages\pip-19.0.3-py3.8.egg
C:\Users\hty11\PycharmProjects\typeidea

  • 写回答

1条回答 默认 最新

  • 家在田塍 2020-02-09 14:29
    关注

    你的models.py应该放在typeidea下面,需要和你引用的库在同一个根目录下

    评论

报告相同问题?

悬赏问题

  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。