I use the following project structure. A project for me is all that PyCharm sees. Those. the project is not only django startproject but also all sorts of documentation files, docker-compose configs, etc. It looks like this:
. (ΠΠ°ΠΏΠΊΠ° ΠΏΡΠΎΠ΅ΠΊΡΠ° PyCharm) βββ env βββ site_proj (Π‘Π°ΠΌ ΠΏΡΠΎΠ΅ΠΊΡ Django) β βββ chat_app β β βββ migrations β β βββ __pycache__ β β βββ templates β β βββ admin.py β β βββ apps.py β β βββ consumers.py β β βββ __init__.py β β βββ models.py β β βββ routing.py β β βββ tests.py β β βββ urls.py β β βββ views.py β βββ site_proj β β βββ __pycache__ β β βββ __init__.py β β βββ routing.py β β βββ settings.py β β βββ urls.py β β βββ wsgi.py β βββ db.sqlite3 β βββ manage.py βββ docker-compose.yml βββ README.md Those. Everything related to the Django project lies in site_proj and does not interfere with files that do not belong to Django.
From here there are problems with import:
one)
# ./site_proj/site_proj/routing.py from ..site_proj import chat_app ValueError: attempted relative import beyond top-level package
2)
# ./site_proj/site_proj/routing.py from site_proj import chat_app # PyCharm autocomplete django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'site_proj.routing'
3)
# ./site_proj/site_proj/routing.py from site_proj.chat_app import routing django.core.exceptions.ImproperlyConfigured: Cannot import ASGI_APPLICATION module 'site_proj.routing'
If the root folder for the IDE is the Django project folder, then everything will be ok, but I donβt want to. What is the problem and how to solve it?

import chat_appshould work fine - andreymal