Django: not a single module with a model name

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

 from location.models import Zipcode 

But in the installed location application in my project there is a models.py , __init__.py and Zipcode .

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

+4
source share
1 answer

Thanks for your comment @Marcin. Turns out 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 the moral of this story, I think, is to check that you have no name conflicts in the application when you try to import the same application ..

+3
source

Source: https://habr.com/ru/post/1492147/


All Articles