Part 6: Get started with Python: Build your first Django Application in PTVS

This is a tutorial series which will teach you how to code in Python. We will start with the absolute basics of installation of Python in Windows and Python Tools in Visual Studio. We will then go through basic constructs in Python and write a couple of programs to summarize what we have learned.

Part 1: Get Started with Python summarized the steps involved to setup Python and Visual Studio for Python Development. We essentially learned how to install Python in Windows, Visual Studio and Python Tools for Visual Studio.

Part 2: Get Started with Python took you through the basics in programming constructs such as output, input, variables and control flow statements including conditional statements and loops including while and for. Using these tools was enough to get started with coding basic applications in Python.

Part 3: Get Started with Python: Functions and File Handling, as the topic suggests, dealt with functions and file handling in Python. We went through the ‘def’ construct used in function definition and file handling constructs for open. read and write. Essentially, by this topic we covered the basics of programming in Python.

Part 4: Get Started with Python: Object Oriented Approach gives an insight into the object oriented approach to programming in Python, primarily discussing objects and classes.

Part 5: Get Started with Python: Debugging in PTVS talks about some of the unique feature in PTVS, specifically debugging tools such as Mixed Mode Debugging and Remote Debugging.

As you can see above, the intent of this tutorial was to get you started on Python. In the last 5 sections, I have tried to cover basic and requisite concepts which will get you started on Python. Let this final section, Part 6,  be a culmination of your learning's and application of your knowledge in Python by creating a basic Web Django Application. Yes, PTVS has some cool templates to play around with for sure! So lets get started.

Let’s create a new project (File > New Project > Python > Django Project and give it a name.


Let’s create a Virtual Environment to install the dependencies. This is also necessary if you intend to publish it in Azure.
To add a Virtual Environment, right click on the ‘Python Environment’ in the Solution Explorer and select “Add Virtual Environment”


Once this is done, you will need to install the Django Package. Right Click on env, select “Install Python Package” and search Django. As some of you may already know, this is similar to installing Nuget packages on VS, the difference being this uses pip, the Python Package Manager. Since this is quite a large package, it takes time to install this.


Let’s verify if we have installed it correctly. In order to do so, press F5. This will launch the Django development server and start your web browser. You should see the following page:


Now that you are all set, you can start building your Django application. Select the project node, Add > Django app, and name the app accordingly. This will create a folder for the application, with boilerplate code for commonly used applications. Once you have developed your app, you can go ahead and deploy the app in Azure where you can either host on a regular Azure Website or on a Virtual Machine. Refer to this tutorial which shows you how to develop a ‘Poll’ app on Django in PTVS and then host it on Azure Websites. The tutorial is also available on video as below for your reference.




In the last 6 weeks, I have taken you through some of the key features of Python and how Python Tools in Visual Studio seamlessly integrates the entire experience on Visual Studio. We started with installation of Python tools in Visual Studio, discussed variables, methods, an Object Oriented approach in Python, followed by new debugging tools in PTVS. We ended with a developing a Django app and how it can be deployed on Azure. Go through the different parts of the tutorial. Share your experience using PTVS with me. I can be reached on twitter @AdarshaDatta.


Comments (0)

Skip to main content