I have a python script named "WhatsApp_to_Excel.py". There is a variable there that I need to use for a Django project I'm making. So I'm trying to import the module to the models.py file. This is my folder hierarchy-
Then I make my import like this-
But even though pycharm auto-completed the module's name, when I run the server I get the no module found error.
I'm running my code from a virtual environment, but I don't see how this can be the problem. I've tried to import the module in an absolute way, but it didn't work and it's rather weird that pycharm DOES recognize the module.
Does anybody Have any ideas on how to solve the problem? Would appreciate any help :-)
CodePudding user response:
Try to put that WhatsApp_to_Excel.py file in the same directory of models.py
CodePudding user response:
Thank you guys! I solved the problem using your advice-
I moved my python script inside the folder with models.py (an init file was created automatically).
I've imported a variable from my script using this code
from .WhatsApp_to_Excel import TXT_PATH
And it works!!