Join my Laravel for REST API's course on Udemy 👀

`Class has no 'objects' member` error with Pylint

April 6, 2021  ‐ 2 min read

When you're using Pylint with Django you may encounter warnings like Class ‘Question’ has no ‘objects’ member pylint(no-member). Pylint helps you to find possible problems with your code, in this case it doesn't mean there is an error per se.

In order to use Pylint effectively with Django make sure that you have the Django plugin for Pylint installed. Since that is just a Python package you can install it with pip.

$ pip install pylint-django

If you're using a Pylint extension in your editor you might need to add some config settings.

With Visual Studio Code you can add the following snippet to your editor settings.json. To open these settings with the shortcut ctrl-shift-p (or cmd-shift-p on Mac) for the Command Palette and run the command: Preferences: Open Settings (JSON).

Visual Studio Code command palette

This opens up the settings JSON file. Here you should either look for the python.linting.pylintArgs or add it yourself and make sure that --load-plugins=pylint_django is passed as an argument.

  "python.linting.pylintArgs": [

Another possible issue with Visual Studio Code can be Python interpreter that is used. This should be same Python for which you installed pylint-django. This is especially something you want to pay attention to if you're using a virtual environment. If so, make sure that you select the Python interpreter in your virtual environment. You can do this by running the Python: Select Interpreter command that can be found in the VS Code Command Palette as well.