pycharmDjango项目下无法导包ImportError: attempted relative import with no known parent package

pycharmDjango项目下无法导包ImportError: attempted relative import with no known parent package

from app_sleepfox.pachongpage.conn_mysql import ConnectMysql #正确的导包方法
# from .conn_mysql import ConnectMysql #错误的导包

pycharmDjango项目下无法导包ImportError: attempted relative import with no known parent package_第1张图片

解决方法:

从应用下去导你的文件如
from app_sleepfox.pachongpage.conn_mysql import ConnectMysql

你可能感兴趣的:(python,python,django,pycharm)