importing modules

  • 2
  • 6

PyCharm is not recognizing paths that I want to import.

My file structure is like this:
project:
– web:
– djanogapp:
– app1
– app2
– app3
– other folders

django lives in djangoapp. Let's say that I want to import a module from app1 into app2. Autocomplete and such only works if I do something like:

from djangoapp.app1.models import SomeModel

I want to ommit djangoapp from the import statement, so that I can write it as:

from app1.models import SomeModel

How do I go about setting up PyCharm for that?

Thanks.
You need to mark the djangoapp directory as a source root in Settings | Project Structure.
--
Dmitry Jemerov, Chief Technology Officer, JetBrains

Thanks. That did it!

Sent from a mobile device.