简体   繁体   中英

ModuleNotFoundError: No module named 'my_app'

I am trying to make a custom manager that will run a function from another file in a sibling directory, but this error keeps popping up. I have tried:

1) Adding the module to my PYTHONPATH.
2) Adding init .py files.
3) Appending the module to sys.path.

I am using Python3 and Django.

  • /app
  • --- /managers
  • -------/manager.py <--- /*importing code here*/
  • --- /my_app
  • -------/request.py <--- /*code to be imported*/

None of these have worked.

it should work with

from .. import my_app

or

from ..my_app import request 

(Be careful with a name like request , it could conflict the argument request used inside the views)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM