Partager via


Python item templates

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The item templates are available in Python projects through the Project > Add New Item menu command, or the Add > New Item command on the context menu in Solution Explorer.

Add New Item dialog box

Using the name you provide for the item, a template typically creates one or more files and folders within the currently selected folder in the project (right-clicking a folder to bring up the context menu automatically selects that folder). Adding an item includes it in the Visual Studio project, and the item appears in Solution Explorer.

The following table briefly explains the effect of each item template within a Python project:

Template What the template creates
Empty Python File An empty file with the .py extension.
Python class A .py file containing a single empty Python class definition.
Python Package A folder that contains an __init__.py file.
Python Unit Test A .py file with a single unit test based on the unittest framework, along with a call to unittest.main() to run the tests in the file.
HTML Page An .html file with a simple page structure consisting of a <head> and <body> element.
JavaScript An empty .js file.
Style Sheet A .css file containing an empty style for body.
Text file An empty .txt file.
Django 1.9 App
Django 1.4 App
A folder with the name of the app, which contains the core files for a Django app as explained in Learn Django in Visual Studio, Step 2-2 for Django 1.9. For Django 1.4, the migrations folder, the admin.py file, and the apps.py file are not included.
Web Role Support Files A bin folder in the project root (regardless of the selected folder in the project). The folder contains a default deployment script and a web.config file for Azure Cloud Service web roles. The template also includes a readme.html file that explains the details.
Worker Role Support Files A bin folder in the project root (regardless of the selected folder in the project). The folder contains default deployment and launch script, along with a web.config file, for Azure Cloud Service worker roles. The template also includes a readme.html file that explains the details.
Azure web.config (FastCGI) A web.config file that contains entries for apps using a WSGI object to handle incoming connections. This file is typically deployed to the root of a web server running IIS. For more information, see Configure an app for IIS.
Azure web.config (HttpPlatformHandler) A web.config file that contains entries for apps that listen on a socket for incoming connections. This file is typically deployed to the root of a web server running IIS, such as Azure App Service. For more information, see Configure an app for IIS.
Azure static files web.config A web.config file typically added to a static folder (or other folder containing static items) to disable Python handling for that folder. This config file works in conjunction with one of the FastCGI or HttpPlatformHandler config files above. For more information, see Configure an app for IIS.
Azure Remote debugging web.config Deprecated (was used for remote debugging on Azure App Service for Windows, which is no longer supported).

See also