PyCharm not recognizing Django project imports: from my_app.models import thing

I was having this issue using a “2 Scoops of Django” project layout, e.g.

/project_root
    /project_dir
        /config
            /settings
        /my_app
            /tests
            models.py
    /requirements
    readme.rst

The code was working, but in /tests, IntelliJ/PyCharm showed an unresolved reference:

from my_app.models import Something

I had all the __init__.py files in place. I ended up having to set the sources root to project_dir:

Right-click on project_dir, Mark Directory as > Sources Root

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)