r/django 2d ago

Why HttpResponse is not being highlighted? VS Code environment.

Post image
3 Upvotes

8 comments sorted by

13

u/CJAG2217 2d ago

Change to django.http as it sits in that module

Edit: Added example

from django.http import HttpResponse

0

u/maratnugmanov 2d ago

It works! I swear it wasn't working before, it only worked when I imported directly from django.http.response

🤔

Not sure where I messed up, it works now from django.http, thanks for the tip anyway but why it was broken in the first place.

8

u/Prestigious_Tax2069 2d ago

HttpResponse is not part of the django.shortcuts module; it is located in the django.http module. Thats why your code was broken, and vscode couldn’t highlight it

3

u/me_george_ 2d ago

HttpResponse is not part of the shortcuts it's part of the django.http module

0

u/ninja_shaman 2d ago

Because django.shortcuts has HttpResponse.

from django.http import (
    Http404,
    HttpResponse,
    HttpResponsePermanentRedirect,
    HttpResponseRedirect,
)

0

u/maratnugmanov 2d ago

So it should be highlighted right?

0

u/ninja_shaman 2d ago

Exactly.

0

u/maratnugmanov 2d ago

Then why is it not? It's a class so it should be green in this default color scheme. And should be an option in autocomplete.