[Fixed]-Pycharm (Python IDE) doesn't auto complete Django modules

21đź‘Ť

I had exactly the same issue and couldn’t find a definitive answer. Just invalidating caches didn’t work for me. The problem lies in the fact that, at some point, __init__.py files got registered as text files and messed up the indexing. I worked out this fix:

  • Preferences > File Types > Text Files.
  • Remove __init__.py from the list of registered patterns. Apply.
  • Wait for your indexes to re-build.
  • (If it’s still not working) File > Invalidate caches & restart.
👤stevenholmes

13đź‘Ť

GOTO File > Settings > Langauges & Frameworks > Python Template languages

Select Django in the Template language drop-down.

Jetbrains Docs > Python Template Languages

12đź‘Ť

Nothing here worked for me but Enabling Django support in the settings did:

  1. Settings > Languages & Frameworks > Django
  2. Check of “Enable Django Support”
  3. Fill in the information for your project.
👤Justin Harris

2đź‘Ť

Trivial solution that worked for me: start a new django project using pycharm project options. Try auto-completing using a django import module. If it works, switch back to your original project and auto-complete should be working fine.

I still don’t understand why this works.

👤sista_melody

2đź‘Ť

I worked out this fix:

  1. Go to Preferences > Project:{YourProject} > Python interpreter.
  2. I saw that the field for “Project interpreter” said “2.7…”, but I was coding with python 3.4 and my project was created with python 3.4. Replace the version of python in the “Project interpreter” field with the Python version by means of which you have created your Django project. Apply changes and restart PyCharm.
👤Sergey

0đź‘Ť

you should just change your project interpreter if it is using anaconda or etc to standard python interpreter which may be located in this path (C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\python.exe)

-1đź‘Ť

File--> setting--> project:your_project_name --> python interperter

change python interpreter

👤Shah Vipul

Leave a comment