开发者

python: force non-relative import?

I wanted to make a module called utils/django.py in my project开发者_如何学Python. On the top I have the line:

from django.db import models

However, it tries to import from itself, and that causes an error. I know I can force a relative import with a prepended .:

from .django.db import models

is there any way to force a non-relative import?


No. You need to explicitly enable absolute imports.

from __future__ import absolute_import
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜