我有一个名为Exception in thread "main" java.lang.IllegalArgumentException: Please use the Builder and call setJsonFactory, setTransport, setClientAuthentication and setTokenServerUrl/setTokenServerEncodedUrl
的文件,我正在其中从blog/urls.py
导入一个名为allblogs的函数
即使我写blog/views.py
或import .views
,我也会收到错误import views
答案 0 :(得分:0)
搜索路径必须位于sys.path
中。
参见https://realpython.com/absolute-vs-relative-python-imports/
要列出当前目录,请使用os.curdir
;然后可以进行比较以查看它是否在系统路径中
import os
os.curdir
import sys
for p in sys.path:
print(p);
答案 1 :(得分:0)
在django中,您需要将此添加到setting.py
:
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
然后您可以使用import view.xxxx
这将使您每次导入模块时更加方便。