pylint E1101: Class 'User' has no 'objects' member

1

I am using vscode together with DjangoRestFramework and the same is accusing error in the following line:

res = User.objects.filter(user_nome=value)

But the code runs correctly, the error that the editor shows is as follows:

pylint E1101:Class 'User' has no 'objects' member User: User

On the English stack you have the following related questions:

link

link

But I did not succeed.

I have tried pip install pylint-django both in the virtual environment and on my machine without success.

I tried pylint --load-plugins pylint_django also unsuccessfully

I tried to put this in vscode settings,

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

He stopped accusing this error, but began to accuse several others, such as asking for a semicolon at the end of a python statement.

I tried pylint --ignored-classes= User It returns me the following

No config file found, using default configuration
************* Module User
F:  1, 0: No module named User (fatal)

System version, Usage Fedora Red Hat 8.1.1-1 .

pylint --version
No config file found, using default configuration
pylint 1.9.2, 
astroid 1.6.5
Python 2.7.15 (default, May 16 2018, 17:50:09) 

The problem continues when I use another class in place of User

    
asked by anonymous 18.07.2018 / 16:02

1 answer

1

The User class in models.py needs to have the user attribute to work. If so, put dunderscore between the attribute name and the filter.

res = User.objects.filter(user__nome=value)
    
18.07.2018 / 22:33