Installing and using the pylint Django plug-in in vscode to solve some unnecessary error prompts of pylint


Microsoft’s vscode editor is a good thing. It is very convenient to edit Python program through vscode. It is recommended to install the python plug-in. It is believed that the installation of the plug-in is unnecessary for people who have used vscode, as shown in the figure.

Python plug-in uses a tool of pylint by default, which is specially used to detect whether Python code is written incorrectly and in accordance with good habits. The python official website ( has a special section to introduce the recommended Python code habits, such as the naming rules of classes, functions, etc., which can make your code higher level.

Then pylint has some shortcomings in the face of Django framework, because Django uses a large number of metaprogramming ideas and duck models, so that it will modify many object properties and behaviors (sister, I don’t know what kind of ghost metaprogramming is), but this brings great difficulties to syntax checking programs like pylint. Typically, the model layer object integrated with django.db.models.model does not have the objects attribute at compile time, but it does at run time. As a result, pylint will report “has no objects attributes” and other errors when we write code. Although it does not affect the operation of the program, it will affect our mood. So someone specially developed the pylint plug-in, pylint Django. Here is a detailed introduction ( The author seems to be the developer of the plug-in, like a warm-hearted programmer. Use PIP install pylint Django to install. You can use pylint — load plugins pylint_django [other option] on the command line. Please note that it is pylint_django, not pylint Django.

However, I’m talking about how to configure and use pylint Django in vscode. The method is very simple. Select File – > Preferences – > settings in vscode to open the settings file of vscode, and then add “- load plugins” and “pylint UU Django” in “python. Linking. Pylintargs”. As shown in the picture:

If necessary, restart vscode, and then pylint will not report an error.

Developer supplement: PIP support is required during installation.