1

Why doesn't VSC offer me imports from Django Rest Framework?

For example, I want to quickly do from rest_framework.response import Response, but VSC doesn't want to help me ;( Example

finegorko
  • 57
  • 8

1 Answers1

4

Even with the correct interpreter path and DRF installed in virtual env and pylance autoImportCompletions enabled, I still couldn't get it working...what ultimately did the trick was adding this to settings.json:

  "python.analysis.autoImportCompletions": true,
  "python.analysis.indexing": true,
  "python.analysis.packageIndexDepths": [
    {
      "name": "django",
      "depth": 10,
      "includeAllSymbols": true,
    },
    {
      "name": "rest_framework",
      "depth": 10,
      "includeAllSymbols": true,
    }
  ]

enter image description here

Rok Sprogar
  • 2,261
  • 2
  • 17
  • 27
  • And if it still doesn't work, take a look at this issue (2 days old at the time of writing): https://github.com/microsoft/pylance-release/issues/3648 – Rok Sprogar Nov 19 '22 at 14:48