开发者

Django: How to handle imports in a reusable app

I'm j开发者_运维知识库ust starting with django. It is not quite clear to me, how should I write an app I could reuse later. In every tutorial I read I see the same piece of code:

view.py
from project.app.models import MyModel

So, if I move my apps to another project, I'll have to modify the "project.app.models" so that it looks like "project2.app.models" for every app I move. Is there a way to avoid that?

Thanks in advance.


You should update your Python path with the directory containing your apps.

This way you just have to :

from app.models import MyModel
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜