Andres Manuel Diaz
Andres Manuel Diaz

Reputation: 159

vscode doesn't recognized my django module app. Warning from vscode

I installed some extensions in Visual Studio Code for develop in Django. My only problem is when I'm trying to do this;

Opening folder in VSCode

import views from my_app

Complete view of the explorer

launch.json

from my_app_name import views

I received a warning from Visual Studio Code.

If a typed like this;

from . import views

I don't received any warning! But a would prefer the other form above.

  1. I have python 3.x installed on my laptop.
  2. I have Anaconda environment created.
  3. I have some extensions installed (Python, Django, Pylint,...)

Note: My project run well because is only a warning but I would prefer that warning disappear.

Fast solution for me:

open project folder Just open one project directory.

Upvotes: 1

Views: 6905

Answers (2)

shaheen g
shaheen g

Reputation: 781

If you get the Error that django-not-configured (E5110): *Django was not configured, you also need to run pylint --django-settings-module=<YOUR DJANGO PROJECT NAME>.settings or add it to your settings.json file of your Django project. I prefer the latter and therefore my settings.json has these entries:

    "python.linting.pylintArgs": [
        "--load-plugins","pylint_django",
        "--django-settings-module","<YOUR DJANGO PROJECT NAME>.settings",
    ],

NOTE: The <YOUR DJANGO PROJECT NAME> should be replaced by the name of your Django project.

Upvotes: 0

ohlr
ohlr

Reputation: 1909

There might be several issues here (If the Warning appears only in the problems panel, I believe you should start with the last one)

To rule them out try this:

Django related:

create a new project and add a module

django-admin startproject your_project

python manage.py startapp your_app


Visual Studio Code related:

Chose the interpreter+linter(pylint) from your conda environment vs-code-interpreter


Visual Studio Code / Django related:

Add this to your workspace settings

"python.linting.pylintArgs": ["--load-plugins", "pylint_django"]

vs code linting in django Therefore you need this plugin:pylint-django

Upvotes: 6

Related Questions