This post is about creating a Django project in Visual Studio. If you wish to create the project manually or you want to use any other text editor, please read this post about creating a Django project manually.
Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs for Microsoft Windows, as well as web sites, web apps, web services, and mobile apps. I’ve been using Visual Studio for the past few years and it’s the best IDE I’ve ever used.
Creating a Django project in VS
In this tutorial, I’ll be using Visual Studio Community edition 2017. Assuming you have installed Python Support in your IDE, let’s dive into the topic.
Note: At the time of writing this post, Python development is not supported in Visual Studio for Mac. On Mac and Linux, use the Python extension in Visual Studio Code.
Create a new Visual Studio Project:
Select File > New > Project > Python > Django Web Project template.
After clicking the OK button, Visual Studio will show a dialog box saying This project requires external packages. Select Install Into A Virtual Environment. If you wish to install the packages later, select I will install them myself.
3. If the project is successfully created, you’ll have a project structure similar to the one shown below.
Running the project
To run the project, select Debug > Start Debugging (F5) or use the Web Server button on the toolbar. This will open a Web Browser and you’ll see a welcome page.
Creating the virtual environment
If you have opted not to install the project dependencies as specified in step 2, right-click the Python Environments node and select Add Virtual Environment to add the dependencies.