Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Support Django model objects in IntelliSense #1934

Closed

Description

@DoofCoder

This case is similar to microsoft/vscode-python#1072

Environment data

  • VS Code version: 1.25.1
  • Extension version (available under the Extensions sidebar): 2018.7.1
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda Python 3.6.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): Conda
  • Relevant/affected Python packages and their versions: Django 2.0.6

Actual behavior

Intellisense/pylint do not offer autocompletion for a member variable inherited from a base class and shows it as a problem: E1101:Class 'Question' has no 'objects' member

The code runs exactly as intended without errors.

I am actually following the Django tutorial from the official site.

Expected behavior

The object's member should be shown in intellisense and it shouldn't log it as a problem

Steps to reproduce:

It happens when following the tutorial from djangoproject.org:
https://docs.djangoproject.com/en/2.0/intro/tutorial03/

in section: Write views that actually do something:

from django.http import HttpResponse
from .models import Question

def index(request):
    latest_question_list = Question.objects.order_by('-pub_date')[:5]
    output = ', '.join([q.question_text for q in latest_question_list])
    return HttpResponse(output)

Logs

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

Everything runs ok. there is actually nothing in output.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

System check identified no issues (0 silenced).
July 28, 2018 - 10:47:36
Django version 2.0.6, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[28/Jul/2018 10:47:43] "GET /polls/ HTTP/1.1" 200 11

Output from 'Problems'

{
	"resource": "/c:/Users/Ramon Leon/Documents/DjangoProjects/mysite/polls/views.py",
	"owner": "python",
	"code": "E1101",
	"severity": 8,
	"message": "E1101:Class 'Question' has no 'objects' member",
	"source": "pylint",
	"startLineNumber": 9,
	"startColumn": 28,
	"endLineNumber": 9,
	"endColumn": 28
}

Activity

  1. changed the title [-]IntelliSense stopped providing completions for inherited variables and methods in 2018.7.1[/-] [+]Support Django model objects in IntelliSense[/+] on Jul 30, 2018
  2. brettcannon commented on Jul 30, 2018

    @brettcannon
    Member

    That's because Django's objects() method is magical and not discoverable from code analysis. IOW this requires special Django code that both Jedi, Pylint, and our language server do not have. I have made this a feature request, though, for our language server to add support.

  3. yozlet commented on Aug 16, 2018

    @yozlet

    Instead of special-casing Django in the LS, is it possible for users of magic-dependent frameworks to provide explicit hint data to the analyzer?

    I ask this as a Django user who'd find Django support super useful, but if some kind of hint data format/API is possible then it'd open the possibilities up wider, and it'd make the feature less brittle. However, it might also be more work and create a longer-term liability in supporting an open hinting system.

  4. d3r3kk commented on Aug 16, 2018

    @d3r3kk

    Yoz Grahame (@yozlet) good point! I'm sure the language server team will handle it as generically as possible, with the Language Server Protocol and niceties like the DocumentSelector I think they will be able to handle 'special cases' like this.

  5. simonmelouah commented on Dec 16, 2018

    @simonmelouah

    Would love this support too!

  6. locked and limited conversation to collaborators on Dec 17, 2018
  7. unlocked this conversation on Mar 11, 2020
  8. jakebailey commented on Mar 11, 2020

    @jakebailey
    Member

    Duplicate of #129.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions