0

I am getting a unresolved import "Blog" in visual studio code. It happened all of a sudden, I am using a venv through conda, I haven't changed anything with the venv, everything is still working, but it's really annoying to have it. As I said, I haven't changed anything in the project that could potentially create this problem intentionally.

from django.contrib import admin
from django.urls import path, include
from Blog import views

urlpatterns = [
    path('admin/', admin.site.urls),
    path("blog/", include("Blog.urls")),
    path("index/", views.index.as_view(), name="index"),
    path("", include("django.contrib.auth.urls")),
    path("signup/", views.SignUp.as_view(), name="SignUp"),
    path("accounts/", include("django.contrib.auth.urls")),
]
Filip
  • 855
  • 2
  • 18
  • 38

2 Answers2

0

If the Blog module is in a parent directory, then you might need a relative import:

from ...Blog import views

Or if it's in the same directory, you'll also need a relative import:

from .Blog import views

More on relative imports

Another option is to set your project root in VS Code.

Nikolas Stevenson-Molnar
  • 4,235
  • 1
  • 22
  • 31
0

The problem was just a bug caused by a Visual Studio Code extension called "Visual Studio IntelliCode - Preview"

Filip
  • 855
  • 2
  • 18
  • 38