How to reference python package when filename contains a period

前端 未结 5 376
一生所求
一生所求 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:11

    You are not referencing files in the import statement, you are referencing modules and packages.

    Please read the docs, they are very clear on that matter.

    Anyway, since you are using django, the usual approach won't work. If you want to keep models in separate files, rather than in models.py, you have to take extra steps, outlined, for example, here.

    Edit:
    Well, I don't really know what the questioneer means when he mentions admin and whether or not it is related to the admin interface of django. My points still stand.

提交回复
热议问题