Django and Visual Studio Code

43 views
Skip to first unread message

Simon Connah

unread,
Apr 30, 2018, 7:38:51 AM4/30/18
to django...@googlegroups.com
I've got most of Visual Studio Code configured for Django development
(I'm trying it out to see if I can ditch PyCharm and save some money)
and almost everything seems OK.

I set the Python path to be the one in the virtual environment, and if
Visual Studio Code needs to install any modules, they go into the
virtual environment.

The major problem is that when I open a terminal in Visual Studio
Code, it doesn't automatically activate the virtual environment, so I
have to source it manually.

In addition to that, I haven't managed to get debugging working even
after reading a few tutorials on the subject.

Has anyone got any tips for setting up these two things, please?

Thank you.

Simon.

Scot Hacker

unread,
May 1, 2018, 2:11:23 AM5/1/18
to Django users


On Monday, April 30, 2018 at 4:38:51 AM UTC-7, Simon Connah wrote:
I've got most of Visual Studio Code configured for Django development
(I'm trying it out to see if I can ditch PyCharm and save some money)
and almost everything seems OK.

After moving through BBEdit, TextMate, Sublime and Atom over the years, I'm feeling like VSCode is the most polished, professional editor/IDE I've ever used (never did the pycharm thing). Learn a dozen keyboard shortcuts, and it's like it's reading your mind. 
 

I set the Python path to be the one in the virtual environment, and if
Visual Studio Code needs to install any modules, they go into the
virtual environment.

I use pipenv, and don't like this approach, as it rewrites Pipfile, which is in vcs and gets shared with the team, who all use different editors. I assume it does similar for requirements.txt. Dependencies specific to a given editor should not be forced on an editor-agnostic team. 
 

The major problem is that when I open a terminal in Visual Studio
Code, it doesn't automatically activate the virtual environment, so I
have to source it manually.

When you open a bash terminal, does it automatically activate an environment? I wouldn't expect it to be different in the editor's terminal, and `pipenv shell` still works normally. That said, you might be able to pass startup arguments via `terminal.integrated.shellArgs.*`
 

In addition to that, I haven't managed to get debugging working even
after reading a few tutorials on the subject.

You haven't really told us what's working/not working or how you've gone about setting it up. I just use icecream and good old pdb and log statements (haven't tried deep vscode integration). 

./s
 
Reply all
Reply to author
Forward
0 new messages