Django Web Project templates for Python in Visual Studio

Django is a high-level Python framework designed for rapid, secure, and scalable web development. Python support in Visual Studio provides several project templates to set up the structure of a Django-based web application.

The templates are available in Visual Studio under File > New > Project and include the Blank Django Web Project and Django Web Project. For a walkthrough of the templates, see the Work with the Django web framework in Visual Studio tutorial series.

Intellisense features

Visual Studio provides full IntelliSense support for Django projects, including the following features:

  • Context variables passed into the template:

    Screenshot that shows IntelliSense support for context variables used in Django development in Visual Studio.

  • Tagging and filtering for both built-ins and user-defined items:

    Screenshot that shows IntelliSense support of tags and filters used in Django development in Visual Studio.

  • Syntax coloring for embedded CSS and JavaScript elements:

    Screenshot that shows IntelliSense support for CSS used in Django development in Visual Studio.

    Screenshot that shows IntelliSense support for JavaScript used in Django development in Visual Studio.

Debugging support

Visual Studio also provides full debugging support for Django projects:

Screenshot that shows Debugger breakpoints used in Django development in Visual Studio.

Django management console

The Django management console is accessed through various commands on the Django Project menu or by right-clicking the Django project in Solution Explorer.

  • Open Django Shell: Opens a shell in your application context that enables you to manipulate your models:

    Screenshot that shows the results of the Open Django Shell command in Visual Studio.

  • Django Sync DB: Runs the manage.py syncdb command in an Interactive Window:

    Screenshot that shows the result of the Django Sync DB command in Visual Studio.

  • Collect Static: Runs the manage.py collectstatic --noinput command to copy all static files to the path specified by the STATIC_ROOT variable in your _settings.py file:

    Screenshot that shows the result of the Collect Static command in Visual Studio.

  • Validate: Runs the manage.py validate command that reports any validation errors in the installed models specified by the INSTALLED_APPS variable in your settings.py file:

    Screenshot that shows the result of the Validate command in Visual Studio.

Important

Django projects are typically managed through a manage.py file and Visual Studio follows this approach. If you stop using the manage.py file as the entry point, you essentially break the project file. In this case, you need to recreate the project from existing files without marking it as a Django project.