Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: No module named models

ImportError: no module named location.models at the following line:

from location.models import Zipcode

But there is a models.py, an __init__.py, and a Zipcode model in an installed app called location in my project.

Further, the module is easily imported in the python shell using the same command. What could be the problem here? Thanks for your ideas!

like image 281
Nick B Avatar asked Oct 03 '22 12:10

Nick B


1 Answers

Thanks for your commentary @Marcin. Turns out that I had a file called location.py in my views.py folder, which was causing some kind of conflict. I renamed this file location_view.py and voila.

So moral of the story, I guess, is check to make sure that you dont have any name conflicts in an app when you are trying to import an app of the same name..

like image 99
Nick B Avatar answered Oct 07 '22 02:10

Nick B