Pylint-django raising error about Django not being configured when that’s not the case (VSCode)

Add the --django-settings-module argument the VS Code settings:

  {
    "python.linting.pylintArgs": [
        [...]
        "--django-settings-module=<mainapp>.settings",
    ]
  }

Change <mainapp> to be your main app directory. For example, if your settings.py was in sweetstuff/settings.py then the argument value would be sweetstuff.settings. This is the same format as you would import the settings module from inside a Python module or the Django shell.

This problem came up for me in some Bitbucket Pipelines. I solved it there by creating the DJANGO_SETTINGS_MODULE as a repository variable which is then made available as an environment variable when Pylint is run.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)