By using our website, you agree to our privacy policy

Use VS Code for Python and Django Development

Use VS Code for Python and Django Development
Photo by Chris Ried on Unsplash

Visual Studio Code is an editor developed by Microsoft. I have been using this editor for Python development for sometime now. Previously I have been using PyCharm Community Edition for development, but I had to switch to an editor which was less resource consuming than PyCharm, since I have been using VS Code.

It was initially suggested to me by one of my colleagues. My first impression was, what is this? Is it really usable? Is it as bad as Atom?(I have a dreadful experience with Atom, although Atom is maybe as good as VS Code). But instead, I found that it is really useful, user-friendly and has lots of useful features.

Let us check out how we can use VS Code to develop Production grade Python applications.

Go to settings

You can check VS code’s documentation on how to go to User and Workspace Settings. I prefer to use Command Palette for them.

To go to Workspace Settings, press CTRL+SHIFT+P(CMD+SHIFT+P for MacOS), it will open up Command Palette, then type Preferences: Open Workspace Settings. After pressing Enter(or click), you will go into Workspace settings(JSON).

And to go to User settings,press CTRL+SHIFT+P(CMD+SHIFT+P for MacOS) and type Preferences: Open Settings(JSON).

Configuring python

For python related configurations, we are going to use Workspace Settings.

Install python plugin

For using pythonic features, you need to install plugin Python VS Code To do that, go to Extensions Section of VS Code(marked blue in the image given below), in search section, type python; and install the red marked package called Python by Don Jayamanne(Now Maintained by Microsoft).


Add virtual environment

Here is how to configure the virtual environment:

  "python.pythonPath": "/path/to/virtualenv/bin/python"

That should be enough to let you use the virtual environment for development. If you want to add your own modules, then add this settings:

  "python.autoComplete.extraPaths": ["./path-to-your-code"]

After that, let us add some more features which are useful to develop python codes.

Using PEP8 and lint

To add them to vs code, add the following key values to above dictionary:

  "python.linting.pep8Enabled": true,
  "python.linting.pylintPath": "/path/to/virtualenv/bin/pylint",
  "python.linting.pylintArgs": ["--load-plugins", "pylint_django"],
  "python.linting.pylintEnabled": true

To use the above features, editor will prompt you to install pylint and autopep8, or you can install them directly in virtual environment:

pip install autopep8
pip install pylint

Generic configurations

For generic related configurations, we are going to use User Settings.

Format on save

Add this like in dict: "editor.formatOnSave": true It will auto format code (language does not matter).

Add ruler in editor

Adding rulers in the editor gives you a better idea of how many words you will put on a single line, in Pep8 Standard, it’s 79. So let’s add the following key and values in the settings dictionary:

  "editor.rulers": [80, 120]

Ignoring unnecessary files

To ignore unnecessary files, add this following lines:

  "files.exclude": {
    "**/.git": true,
    "**/.svn": true,
    "**/.hg": true,
    "**/CVS": true,
    "**/.DS_Store": true,
    ".vscode": true,
    "**/*.pyc": true,
    "**/__pycache__/": true

Disable preview

When you open a file using an import file or try to go back to the declaration of the code, vs code intends to open it in a preview window, which sometimes is annoying when you want to do it multiple steps/times. To disable it, add this:

  "workbench.editor.enablePreview": false

Increase zoom level

You can increase the zoom level of the IDE via adding the following settings:

  "window.zoomLevel": 0.15

Customizing sidebar and topbar(Or any other visual customization)

By default the font size for sidebar and top bar for vscode is not that big. But there are two plugins to handle it.

Custom CSS and JS Loader

You can use Custom CSS and JS Loader, which allow you to override css classes for VS code itself. For example, I use the following styling:

.monaco-tree-row.has-children {
  color: #eee;
  font-size: 15px;

.monaco-tree-row {
  font-weight: 100;
  font-size: 13px;
  color: rgb(223, 223, 223);

.monaco-workbench .tabs-container .tab * {
  font-size: 15px;

.explorer-viewlet {
  font-size: 15px;
  color: rgb(223, 223, 223);
  overflow: auto;

And to add this css in Custom CSS and JS, you need to add the following settings:

  "vscode_custom_css.imports": ["file:///path/to/css/styling.css"]

Please check their documentation on how to add CSS and JS paths to settings in detail.


CustomizeUI relies on the Monkey Patch Extension to inject custom javascript in VSCode. Here is the settings I use (in settings.json) for my Mac:

"customizeUI.stylesheet": {
    ".explorer-viewlet .mac": "font-size: 1.2em !important; overflow: auto; border-left:none!important",

It has some minor advantages over Custom CSS and JS Loader. Like:

  • It won’t show Unsupported on the title-bar or won’t show any error message like Your installation is corrupted.

  • You do not have to reload settings every time VS Code is updated.


You can download any theme from the marketplace and install them. Currently I am using the Material theme.


It is really cool to have debugging feature built-in VS Code. Although as far as I tested, it works perfectly fine on Ubuntu, but not in OSX. So please check before you configure it.

Anyways, the best way to configure it for Django is to add the following lines in launch.js:

  "version": "0.2.0",
  "configurations": [
      "name": "Django",
      "type": "python",
      "request": "launch",
      "stopOnEntry": true,
      "pythonPath": "${config:python.pythonPath}",
      "program": "${workspaceRoot}/",
      "cwd": "${workspaceRoot}",
      "args": ["runserver", "--noreload", "--nothreading"],
      "env": {},
      "envFile": "${workspaceRoot}/path/to/virtualenv",
      "debugOptions": [

Or go to the Debug section(Marked green in the screenshot), click the section marked as yellow and then click add configuration.


Then, click on Django settings to add new Django settings for debugging.


Useful plugins

VS Code Marketplace is really rich with lots of themes, plugins and so on. You can download and use the following plugins from marketplace to enrich your coding experience.

  1. Use Sync to synchronize your settings in between VS Code instances over multiple machines.
  2. You can use Git Blame to see Git blames.
  3. You can use Git LENS to supercharge git functionality.
  4. IntellijIdea Keybindings allows you to use Idea’s shortcut keys in VSCode.
  5. Use Icons to beautify VS Code’s icons.
  6. Use Material Icons for using material icons on the sidebar.
  7. Use Code Spell Checker to check spells in code.

In conclusion

It goes without saying that PyCharm is the best IDE for Python development. It supports refactoring, which makes life a lot easier; has advanced debugging, and its easy to configure. Still, VS code has its own charm. I prefer VS code’s UI, its configurations(which is really dynamic and lots of options) and most importantly, I can do front end development better in VS Code, as PyCharm community edition does not support JS. Also its lightweight(not resource hungry as PyCharm).

Thanks for reading. Cheers!!

Last updated: May 27, 2020

  • x2


Share Your Thoughts
M ↓   Markdown

Pavel Řihošek
Pavel Řihošek
Tuesday, September 5, 2017

I have mypy enabled in my VSCode. It is more useful than pylint IMHO.

Saturday, September 30, 2017

Thanks, I did not know about mypy. Will try it out.

Monday, November 13, 2017

in section IGNORING UNNECESSARY FILES, is should be “**/*.pyc” not “**/*,pyc”

Tuesday, November 14, 2017

Thanks for noticing. Fixing it 😄

Pirmin Schneider
Pirmin Schneider
Saturday, November 25, 2017

I think you should also do `pip install pylint-django` when using

Wednesday, March 14, 2018

Nice article.
Sunday, March 17, 2019

nice information keep sharing

Wednesday, April 4, 2018

For me, I had the key “settings” already inside the workspace folder. I had to add the key-values under settings instead of the root.

Kokila Soral
Kokila Soral
Wednesday, May 9, 2018

This really has covered a great insight on Python. I found myself lucky to visit your page and came across this insightful read on Python tutorial. Please allow me to share similar work on Python training course . Watch and gain knowledge today.

Arun ksamal
Arun ksamal
Wednesday, September 5, 2018

Hi Rudra ,i have try to configure django in vs code but unable to configure .so can you share your number or skaype id so that i will communicate..

Friday, September 7, 2018

Hi Arun, please feel free to share your problem in here. If its too much complicated, then please ask in stackoverflow 😄. Thanks

Tuesday, February 12, 2019

I prefer to use Codelobster IDE for it:

Tuesday, April 7, 2020