Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening Existing Django Project in Visual Studio

I've been using Jetbrains Pycharm for years, but lately the performance has been getting abysmal. I'd like to give Visual Studio a shot.

So I cloned my main repo, through VS, and tried to setup a "Solution". It doesn't seem to recognize my project. In Pycharm I could just clone any old repo, open the folder and then select the interpreter/env I wanted to run it in. I've kinda got it working by creating a django project in VS and then loading all my files in, but that doesn't seem right or viable.

Any tips on how to setup/create a "Solution" for a cloned django project?

Screenshot of My Issue

like image 913
Jon Avatar asked Mar 27 '18 18:03

Jon


People also ask

How do I open an existing Django project in Visual Studio code?

In Visual Studio, select File > New > Project, search for "Django", and select the Blank Django Web Project template, then select Next.

How do I run a Django project already created?

Go to the directory where manage.py file of your Django project is present. It is normally the Base directory of your project. In that directory, Press Shift and Right Click at the same time. The from the Right Click Menu, Click on "Open PowerShell window here".


2 Answers

In Visual Studio create a new project and select Python -> From Existing Python code.
For Location choose the folder of your existing Django project.

Clicking Ok will open the "Create New Project from Existing Python Code Wizard" screen.
Your existing folder should already be entered, so click Next.

On the next screen I kept the Python interpreter settings at default (use global default). Click Next.

Then, be sure to check the box Customize Project Type and select Django Web Project.

Click Finish.

Source

like image 173
veuncent Avatar answered Sep 22 '22 13:09

veuncent


To add to VME's question, this is a screenshot from VS2017:

VS2017 Python existing

Make sure to select Python itself rather than any of the items below (Web etc).

like image 39
Wtower Avatar answered Sep 23 '22 13:09

Wtower