Python-language-server: Support Django object models

Created on 25 Sep 2018  路  9Comments  路  Source: microsoft/python-language-server

Microsoft/vscode-python#2271

enhancement

Most helpful comment

There's a pretty tremendous amount of work in this item; Django models are all metaclass based where everything is generated at runtime, requiring us to essentially reimplement Django again in the analysis as special cases. There are stubs which provide richer info, but require a much better understanding of typing in general (which don't have complete).

Either way, if we aren't actively updating an issue, then there aren't any updates.

All 9 comments

From feedback:

Please see screenshots below from PyCharm and VS Code respectively.
image
image
As you can see the list of hints in PyCharm is more accurate.
This is also the case below when accessing a django model's fields. PyCharm is able to detect that the value will actually be a string whereas VS Code only knows it as a CharField.
image
image

This would be lovely. Also , recognizing import errors specific to Django:

from django.db.models import Q  # notice F isn't imported
#...
cls.get_artists_with_subs().order_by(F("last_refreshed")

VSCode doesn't see any problem with this (until we get an error when this code is run).

Pycharm, on the other hand, complains immediately:

Screen Shot 2019-05-11 at 23 17 25

F not being warned seems like a bug; we'd appreciate it if you could make a new issue so we can fix it.

Has there been any work regarding this?

Go to definition is a hit and miss with Python/Django, in most cases I have to search for class xxx( or def property( in order to find the definition.

Same here. This has been a problem with the language server for years.

There's a pretty tremendous amount of work in this item; Django models are all metaclass based where everything is generated at runtime, requiring us to essentially reimplement Django again in the analysis as special cases. There are stubs which provide richer info, but require a much better understanding of typing in general (which don't have complete).

Either way, if we aren't actively updating an issue, then there aren't any updates.

the new jedi 0.17.1 release now supports Django Meta Classes and added Django Stubs.
If possible upgrade it to the newer version and harness the power of it into vscode-python.

LS does not use Jedi, so this issue is for the Python extension.

LS does not use Jedi, so this issue is for the Python extension.

Ohh, I though my query is mentioned here so I think it is related.
But, please consider the Django Framework Support.

Was this page helpful?
0 / 5 - 0 ratings