Unresolved import references of Django modules
Hello
Out of the blue in all my Django projects( current, old, new) all Django modules imports, Django settings dot notations are marked with red lines(wrong imports). I specially created new Django project to chek it, and output is like this:
for Django imports
for built in python modules:
What i did:
1) Tried to mark all folders as source folders
2)Invalidate cache an restart
3) Used pip and pipenv separatelly
4)Created project on different disc drives
5) remove .virtualennv and pycharm-projects
6) Remove all trash from PATH
7)Re installed python completelly
8)Create Django project from powershell mannually instead of create it via PyCharm
Nothing has helped to solve it.
In general these import issues dont affect Django work, that is all imports in fact work , but PyCharm doesnt see import path for some reason.
my os -windows 10
PyCharm version 2019.2
python 3.8.2 32 bit
Pycharm sees Django in installed modeles
Project structure is like this:
Please sign in to leave a comment.
Where are you navigated if you go to declaration on, let's say, django.urls ?
Andrey, thank you for the answer.
I re-installed PyCharm and it helped.
As far as i remember if you ctrl+B django.urls it would either navigate you to __init__ file of this module or to source code itself, but source code was written as text without coloring ( just plain white text).
I'm using (also) a Mac M1 and I cannot seem to make it work properly there!
Django is installed in my local .venv . If I start typing django a popup will appear with all suggested packages (eg. django as well as other django_* that I have in the site-packages) however if I finish typing "django" and option+click on it it will prompt for "install and import package 'django'".
If I accept the prompt it will import with "import django as django" ???
In any case no other package under django will be detected .
Help please
G Bronzini Could you please show a screenshot of the whole IDE window capturing your project structure and the issue?
Had to:
- remove the virtualenv from the IDE configurations (settings -> Python Interpreter -> Show all and remove it)
- remove .idea folder
- remove .venv (local venv)
- close Pycharm
- recreate the venv
- restart Pycharm and set back everything
and now it works.... But as this is not the first time I had to do this I will update this thread with the requested snapshots.
NB: The "repair IDE" did not otherwise solved the issue.
It's 2024 and the issue seems to be back. I'm on PyCharm 2023.3.4 (Professional Edition) Build #PY-233.14475.56 on an M3Max running Sonoma 14.5. I'm getting the same problem.
Have done everything suggested here and elsewhere (delete and re-created venv and .idea, marked the Django directory as source, invalidated caches and rebuilt them). Only thing I haven't done is re-install PyCharm.
The
django
keyword isn't highlighted, but everything under it has a red underline.Any suggestions?
Unfortunately, I wasn't able to reproduce the issue on 2023.3.5.
Please create an issue on YouTrack so we can properly investigate it. Provide IDE logs (Help | Collect Logs and Diagnostic Data) and share what version of Django being used in your project for faster resolution.