garciaryan
garciaryan

Reputation: 13

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.

Upvotes: 1

Views: 2036

Answers (1)

PRMoureu
PRMoureu

Reputation: 13347

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)

Upvotes: 1

Related Questions