Import model from another app Django

前端 未结 2 1242
滥情空心
滥情空心 2021-02-06 11:27

I have a problem importing a model from another app. I am using Django 2.0.

My project structure looks like this:

--api
  --api
    --settin         


        
2条回答
  •  深忆病人
    2021-02-06 12:14

    Based on your settings and the file directory, the project root is the uppest app directory. So that means that you import the models by writing:

    from product.models import Product

    instead of:

    from api.product.models import Product

    If your IDE suggested that import, something is probably wrong with the project root.

提交回复
热议问题