Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想制作一个utils/django.py在我的项目中调用的模块。在顶部我有一行:
utils/django.py
from django.db import models
但是,它尝试从自身导入,这会导致错误。我知道我可以强制相对导入带有前缀.:
.
from .django.db import models
有没有办法强制非相对导入?
不,您需要明确启用绝对导入。
from __future__ import absolute_import