I have set up a Django Application on a Docker container locally. It runs and can be accessed on the browser on port 8000. However the issue is when I opened the Django Dockerized App in VS Code and tried to write viewsets, serializers and for that I expect VS Code should auto-import them from Django/DRF libraries path, but VS Code neither hints and nor auto-import any of the Django/DRF/Django_Model_Utils. I have tried all the options on this thread but the auto-import doesn't work for dockerized django app when container is opened in VS Code. Even I am able to manually import the Django/DRF modules classes and when ctrl + click, it bring me to the specified class.
But when I write like class UserViewSet(serilizers
and press ctrl + space, it says not doesn't show in the list.
- python path on container: /usr/local/bin/python
- django/drf installed path on container: /usr/local/lib/python3.9/site-packages
I use these path in the settings like this:
{
"python.languageServer": "Default",
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.analysis.extraPaths": [
"/usr/local/lib/python3.9/site-packages",
],
"python.autoComplete.extraPaths": [
"/usr/local/lib/python3.9/site-packages",
],
}
The container user is the root, all the packages installed in the above-given path are installed by root and obviously the server process of VS Code will also be running by this root process or there is any possibility that because of the root user on the container, VS Code can't access the libraries like Django/DRF? I am not sure.
The same happens when I use the following highlighted pre-described VS Code dokcer-compose/Dockerfile settings for Django and Postgres where users is vscode:
Please help me if someone knows or let me know if you need any further information required.
Note: I have many other extensions on my local VS Code like for Angular, PHP, Vue and I install Python and Pylance on the container instance of VS Code server. But nothing works.
However, it can auto-import Python's libraries like datetim, os etc but can't auto-import any of the installed libraries.