How to reference python package when filename contains a period

前端 未结 5 392
一生所求
一生所求 2020-12-03 02:51

I am using django and I have a file named models.admin.py and I want to do the following idea in models.py:

from \"models.admin\" import *

5条回答
  •  感情败类
    2020-12-03 03:19

    The file is called models/admin.py. (Source)

    That is, it should be called admin.py in a directory called models.

    Then you can import using from models.admin import *, assuming that it is in your Python path.

提交回复
热议问题