Django : Unable to import model from another App

后端 未结 2 1012
野性不改
野性不改 2020-11-30 06:57

I was hoping to seek some assistance on this problem I\'m having. I\'m still learning Django (and Python) and come across this particular issue that I\'m unable to locate a

相关标签:
2条回答
  • 2020-11-30 07:13

    Switch

    from News.models import News_Article
    

    to

    from Bolton_GC.News.models import News_Article
    
    0 讨论(0)
  • 2020-11-30 07:18

    Just to elaborate on @TheLifeOfSteve's answer, all the import statements are always relative to your manage.py file.

    If the manage.py file was at the path Bolton_GC/Bolton_GC, then the correct import statement would just be:

    from News.models import News_Article
    

    But in the current directory structure, the following is the correct answer as pointed out by Steve.

    from Bolton_GC.News.models import News_Article
    
    0 讨论(0)
提交回复
热议问题