Pylance use Django V4 after Upgrading to Django V5

I have a model like this:

class Test(models.Model):
    a = models.TextField(null=True, blank=True)
    b = models.TextField(null=True, blank=True)

    class Meta:
        constraints = [
            models.CheckConstraint(
                condition=models.Q(a__isnull=False) | models.Q(b__isnull=False),
                name="not_both_null",
            ),
        ]

After migrating to Django V5, VS code is reporting: enter image description here

However the check constraint has been updated in Django V5: enter image description here

It feels like Pylance is using "cached" old version somehow.

I have tried following ways:

  • Update Python and Pylance extensions to the latest.
  • Restart VS Code/reload window.
  • Restart Pylance server.
  • Set 'python.analysis.extraPaths' to my venv.
  • Reinstall Pylance.

Any other ways I can try?

I have found a temp walkaround, after manually delete the:

~/.vscode/extensions/ms-python.vscode-pylance-2024.12.1/dist/bundled/stubs/django-stubs

Then Pylance is picking up the right definition from my venv. I think this is the pre-bundled version of django-stubs from Microsoft which I might be wrong.

Back to Top