VS Code and Django - drill down variables at design-time

Hi there, I’m using Visual Studio Code for my Django IDE.

I have noticed a problem when trying to drill down into parameter variables passed through to view functions at design time. i.e. when I try to drill down into the request parameter of a view function I can’t seem to do it. Also, subsequently there is no code-completion for the request parameter when I press the space-bar.

I seem to be able to drill down through the other classes without a problem, just not the parameter - request.

Is this normal? If not what’s the issue?


Are you talking about looking at the source code in the editor, or looking at values at runtime in the debugger?

If you’re talking about looking at the source code, that makes sense. The IDE has no way of knowing that the expected parameter is going to be an instance of a Request object. You’re not defining a type in your method, just establishing the fact that you’re going to be called with a positional parameter, and that you’re going to call that parameter “request”.

The VSC editor is capable of some more detailed code-completion if you are using a sufficiently-recent version of Python that supports type hints, and you use the type hints in your code.

In other words, if you were to define your view as:

def my_view(request: HttpRequest):

then, the editor will know how to retrieve the more detailed information about that parameter.

If you’re talking about examining variables in the debugger, I have no problems doing this. The first picture is a picture of the “variables” frame showing the request object in the view, the second picture is of the debug console.

Hope this helps.


Hi, thanks for the super quick reply.
Yes, I’m talking about looking at the source-code at design time. (I’ve updated my og question)
Your solution works, thanks.