Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Django ToolkitNew to Visual Studio Code? Get it now.
Django Toolkit

Django Toolkit

Daryoush Alipour tirotir

|
6 installs
| (0) | Free
Django from zero to production: project wizard, CRUD, login, uploads and REST API scaffolding, one-click manage.py commands, project doctor, explorer and 134 snippets.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Django Toolkit

Build Django projects from zero to production without leaving VS Code.

Create a project, add real web pages, login, uploads and a REST API, and run every manage.py command, all from buttons and one-line prompts. When something is misconfigured, Diagnose Project finds it and fixes it.

By Daryoush Alipour · Part of the Tirotir developer tools.

What you can do

You want to... Use
Start a new project Django: Create Project...
Add a section with list, detail, create, edit, delete pages Django: Scaffold Model with CRUD...
Make the site root (/) show a page Django: Add Home Page
Add login, sign up and a profile page Django: Add Authentication
Accept image or file uploads Django: Set Up Media Files (uploads)
Expose a model as a JSON API Django: Generate REST API for Model...
Open a model's page in the browser Click the link icon next to the model in the sidebar
Find and fix configuration problems Django: Diagnose Project
Run server, migrations, tests, shell... Sidebar Commands, status bar button, or the Command Palette

All commands are in the Command Palette (Ctrl+Shift+P, on Mac Cmd+Shift+P) with the Django: prefix. The same actions are in the Django Toolkit sidebar (the icon in the Activity Bar on the left).

Quick start

  1. Install the extension (Extensions view, ... menu, Install from VSIX..., or install it from the Marketplace).
  2. Make sure Python 3.10 or newer is installed and available as python or python3.
  3. Run Django: Create Project... and answer the prompts (Scenario 1).

The extension activates in any folder that contains a manage.py.


Step-by-step scenarios

Each scenario starts from the result of the previous ones, so you can follow them in order to build one complete site (a small blog with login, comments, photos and an API). Every scenario also works on its own.

Scenario 1: Create a project and see it run

Goal: a working Django site with its admin, in a few minutes.

  1. Run Django: Create Project...
  2. Type a project name, for example mysite, and press Enter.
  3. A folder picker opens. Choose the folder where mysite/ should be created.
  4. Type the first app name, for example blog. (Leave it empty to skip.)
  5. A checklist appears. Keep everything ticked (virtual environment, .gitignore, template and static settings, first migrations) and press Enter.
  6. A second checklist offers extra packages. Tick djangorestframework if you plan Scenario 8 and pillow for Scenario 7, then press Enter.
  7. Watch the notification in the bottom-right corner. It shows each step ("Installing Django" takes the longest). When it finishes, a new notification says Django project "mysite" is ready with the buttons Open Project and Open in New Window. Click Open Project. If you missed it, click the bell icon at the far right of the status bar.
  8. Run Django: Create Superuser. A terminal opens at the bottom: type a username, press Enter, skip the email (press Enter), then type a password twice. Nothing shows while you type a password; that is normal.
  9. Click Run (the Django button in the status bar) or run Django: Run Server.
  10. Open http://127.0.0.1:8000/admin/ and log in.

Result: mysite/ with a .venv, manage.py, a config/ package (settings and root URLs), your blog app registered in INSTALLED_APPS, a templates/ and static/ folder, .gitignore, .env.example and requirements.txt.

The site root http://127.0.0.1:8000/ shows a 404 until you add a home page (Scenario 3). That is normal.

Scenario 2: Add a web section with list, detail, create, edit and delete pages

Goal: manage articles through real web pages, not only the admin.

  1. Click the Django Toolkit icon in the left bar. Under Project, find your blog app.
  2. Click the wand icon next to blog (or run Django: Scaffold Model with CRUD...).
  3. Model name: Article
  4. Fields: title:char, body:text, published:bool, published_on:date?
  5. A notification says the model was scaffolded and shows the page address. Click Migrate & Open Page. The extension creates and applies the migrations, starts the server if it is not running, and opens the list page in your browser. If the browser opens before the server is ready, wait two seconds and refresh.
  6. Try it: click New article, save one, open it, edit it, search for it with the search box, delete it.
  7. Run Django: Run Tests to run the tests that were generated for you.

What was generated, without overwriting anything you had:

File Contents
models.py The Article model with created_at, updated_at, ordering, __str__, get_absolute_url
forms.py A ModelForm (date fields get a date picker)
views.py List (paginated, with search), Detail, Create, Update, Delete class-based views
urls.py Named, namespaced routes
admin.py Admin with list columns, filters, search and date drill-down
templates/blog/ base, list, detail, form and delete-confirmation pages
tests.py Tests for the list, create and detail pages

Which address do I open?

The address is the prefix of your app's include(...) line in the root urls.py, followed by the model's route:

Root urls.py line List page
path("", include("blog.urls")) http://127.0.0.1:8000/articles/
path("blog/", include("blog.urls")) http://127.0.0.1:8000/blog/articles/

The first app made by the project wizard is included at the site root. Apps you add later get their own prefix. The Migrate & Open Page button and the link icon next to a model in the sidebar always open the right address. Django's 404 page also lists every URL it knows, which shows you the correct one.

The route of a model is its name in lowercase with dashes, pluralised: BlogPost becomes blog-posts/.

Scenario 3: Give the site a home page

Goal: the site root / shows a page with links to your sections.

  1. Right-click the blog app in the sidebar and choose Add Home Page (or run Django: Add Home Page).
  2. Click Open Home Page in the notification.

The home page lists a link for every list page the app has, and uses the app's base.html for a consistent look. The route is added to the root urls.py as name="home".

If you also want login links on the home page, run Add Authentication (Scenario 4) before Add Home Page. The command refuses to add a second home page, so to regenerate it, delete the home route and home.html first.

Scenario 4: Add login, sign up and a profile page

Goal: visitors can create an account, log in and log out.

  1. Run Django: Add Authentication (login, signup, profile).
  2. Wait for the notification, then click Open Login Page.
  3. Click Sign up, create an account. You are sent to the login page. Log in. You arrive on your profile page.
  4. Use Log out in the header. (Logout is a button because Django 5 only logs out on a POST request.)

What happens: an accounts app is created (if you do not already have one), registered, and its URLs are included under /accounts/ together with Django's own login, logout and password views. settings.py gets LOGIN_URL, LOGIN_REDIRECT_URL and LOGOUT_REDIRECT_URL. Login, sign-up and profile templates and four tests are generated.

Page Address
Log in /accounts/login/
Sign up /accounts/signup/
Profile /accounts/profile/
Log out the Log out button (a POST to /accounts/logout/)

Running the command again changes nothing.

Scenario 5: Pages only logged-in users can see

Goal: a private notes section where visitors must log in first.

  1. Do Scenario 4 first (so a login page exists).
  2. Open VS Code Settings, search for djangoToolkit.scaffold.requireLogin and turn it on.
  3. Scaffold a model as in Scenario 2: model Note, fields title:char, text:text, owner:fk:auth.User.
  4. Click Migrate & Open Page. While logged out, you are redirected to the login page, and after logging in you return to the notes.

Make notes belong to the person who writes them (optional):

  1. Open blog/views.py, find NoteCreateView, type djfv and press Tab. It adds a form_valid that sets form.instance.owner = self.request.user.
  2. Open blog/forms.py and remove "owner" from the fields list of NoteForm.
  3. In NoteListView.get_queryset, change super().get_queryset() to super().get_queryset().filter(owner=self.request.user).

Turn the setting off again when you want public pages. If you scaffold login-required pages without a login page, Diagnose Project tells you and offers to add authentication.

Scenario 6: Related data in a second app

Goal: comments that belong to an article and to a user.

  1. Run Django: Create App... and type comments. The app is created and registered, and its URLs are included under /comments/.
  2. Click the wand next to comments in the sidebar.
  3. Model name: Comment
  4. Fields: article:fk:blog.Article, author:fk:auth.User, text:text
  5. Click Migrate & Open Page. The page is at /comments/comments/.

blog.Article points to a model in another app. auth.User uses the project's configured user model. The forms show a drop-down for each relation. Add ? after the type (article:fk:blog.Article?) to make a relation optional, and use m2m:Model for many-to-many.

Scenario 7: Image and file uploads

Goal: a photo gallery.

  1. Scaffold a model Photo with fields caption:char, picture:image.
  2. In the notification, click Set Up Media Files. (You can also run Django: Set Up Media Files (uploads) at any time.) This adds MEDIA_URL and MEDIA_ROOT to settings.py and serves uploaded files in development from the root urls.py.
  3. If a warning says Pillow is missing, click Install Pillow.
  4. Click Migrate & Open Page, then upload a picture. It is saved in the media/ folder next to manage.py, and shown on the detail page.

media/ is already in the .gitignore made by the wizard. In production your web server must serve MEDIA_ROOT; Django's development helper is only for local work.

Scenario 8: A REST API for your models

Goal: JSON endpoints for articles.

  1. In the sidebar, expand blog, right-click Article and choose Generate REST API for Model....
  2. If a warning says djangorestframework is missing, click Install It.
  3. Run the server and open http://127.0.0.1:8000/api/blog/articles/.

You get serializers.py, api.py (a ModelViewSet), api_urls.py with a router, rest_framework in INSTALLED_APPS, and the route in the root urls.py. Run it for other models and they join the same router.

By default anyone can read and write through the API. Before going live, add permission_classes = [permissions.IsAuthenticatedOrReadOnly] to the generated ViewSet (the djvs snippet shows the pattern).

Scenario 9: Fix a project that misbehaves

Goal: find out why something returns a 404 or is ignored, and fix it in one click.

  1. Click the pulse icon at the top of the Project panel, or run Django: Diagnose Project.
  2. A list shows what was checked. Each problem has a hint, and warnings that can be fixed say click to fix.
  3. Click Fix N issues automatically at the top, or click a single item to fix just that.

Diagnose Project finds:

Finding Automatic fix
Django not installed in the selected Python environment Offers pip install django
App not in INSTALLED_APPS Adds it
App has urls.py / api_urls.py but is not included in the root urls.py Adds the include(...)
Models exist but no migrations yet Runs makemigrations and migrate
ImageField/FileField without media settings or serving Runs Set Up Media Files
ImageField without Pillow Offers pip install pillow
Views require login but no login page exists Runs Add Authentication
rest_framework used but not installed in settings Adds it
Templates cannot be found (APP_DIRS false, DIRS empty) Reports it
The site root / has no page Offers Add Home Page

Everything it does is also written to the Django Toolkit output channel (View > Output).

Scenario 10: Your daily workflow

Goal: change your data model safely.

  1. Edit models.py. Type djchar, djfk, djm2m and friends for new fields (all snippets start with dj).
  2. Run Django: Make Migrations. (Right-click an app in the sidebar to limit it to that app.)
  3. Run Django: Migrate.
  4. Run Django: Run Tests. (Right-click an app to test only that app.)
  5. Add the new field to forms.py and the templates if the pages should show it.

Other everyday buttons: Show Migrations, Open Django Shell, Create Superuser, Check Project, and Run manage.py Command... for any command, including your own.

Scenario 11: A custom page that is not tied to a model

Goal: an "About" page.

  1. In blog/views.py type djtv and press Tab. Fill in the view name AboutView and the template blog/about.html.
  2. In blog/urls.py type djurlcbv and press Tab. Route about/, view AboutView, name about.
  3. Create blog/templates/blog/about.html. Type djextends and press Tab (blog/base.html), then djblock for content, and write your text.
  4. Open /blog/about/ or /about/, depending on your include prefix (see "Which address do I open?").

Useful template snippets: djfor, djif, djurlt, djstatic, djform, djpaginator, djmessages, djbase.

Scenario 12: Get ready to deploy

Goal: a project you can hand to a server or a container.

  1. Install what you need into the environment (for example gunicorn, whitenoise, psycopg2-binary).
  2. Run Django: Freeze requirements.txt.
  3. Run Django: Check Project and fix any warnings.
  4. In settings.py use the djsettings-env, djsettings-secure, djsettings-static and djsettings-db-pg snippets to read secrets from the environment, enable secure cookies, and configure static files and PostgreSQL.
  5. Run Django: Collect Static Files.
  6. Run Django: Add Docker Files, then docker compose up --build in a terminal.

Add Docker Files creates a Dockerfile, docker-compose.yml and .dockerignore next to manage.py and never overwrites existing files. It uses gunicorn when it is listed in requirements.txt.

Scenario 13: Use it on a project you already have

  1. Open the folder that contains manage.py.
  2. If the wrong Python is used, run Django: Select Python Interpreter... or set djangoToolkit.pythonPath (a .venv, venv or env folder next to the project is detected automatically).
  3. If your settings module is not the default, set djangoToolkit.settingsModule, for example config.settings.dev.
  4. With several projects in one workspace, set djangoToolkit.managePyPath.
  5. Run Django: Diagnose Project for a health check.

Apps and models appear in the sidebar immediately. Scaffolding and every command work on existing code and never overwrite it.


Field types for scaffolding

Write fields as name:type, separated by commas. Add ? to make a field optional.

title:char, body:text, price:decimal?, published:bool, author:fk:auth.User, tags:m2m:Tag
Type Django field Notes
char CharField(max_length=255) Default when no type is given; searchable
text TextField Searchable
int, float, decimal IntegerField, FloatField, DecimalField Decimal is max_digits=10, decimal_places=2
bool BooleanField(default=False)
date, datetime DateField, DateTimeField Forms use date pickers
email, url, slug EmailField, URLField, SlugField Email and slug are searchable
image, file ImageField, FileField Offers Set Up Media Files
json JSONField(default=dict)
fk:Model ForeignKey fk:blog.Article, fk:auth.User
o2o:Model OneToOneField
m2m:Model ManyToManyField

Reserved names (id, pk, created_at, updated_at and Python keywords) are rejected with a clear message. Each generated model also gets created_at and updated_at.

Commands

Command (prefix Django:) ID
Create Project... djangoToolkit.createProject
Create App... djangoToolkit.createApp
Scaffold Model with CRUD... djangoToolkit.scaffoldCrud
Generate REST API for Model... djangoToolkit.generateApi
Add Authentication (login, signup, profile) djangoToolkit.addAuth
Add Home Page djangoToolkit.addHome
Set Up Media Files (uploads) djangoToolkit.setupMedia
Diagnose Project djangoToolkit.diagnose
Open List Page in Browser djangoToolkit.openModelPage
Run Server djangoToolkit.runServer
Stop Server djangoToolkit.stopServer
Restart Server djangoToolkit.restartServer
Server Menu djangoToolkit.serverMenu
Open Server in Browser djangoToolkit.openInBrowser
Make Migrations djangoToolkit.makeMigrations
Migrate djangoToolkit.migrate
Show Migrations djangoToolkit.showMigrations
Create Superuser djangoToolkit.createSuperuser
Open Django Shell djangoToolkit.shell
Open Database Shell djangoToolkit.dbShell
Run Tests djangoToolkit.test
Collect Static Files djangoToolkit.collectStatic
Check Project djangoToolkit.check
Run manage.py Command... djangoToolkit.runManageCommand
Open settings.py djangoToolkit.openSettings
Open Root urls.py djangoToolkit.openRootUrls
Freeze requirements.txt djangoToolkit.freezeRequirements
Install requirements.txt djangoToolkit.installRequirements
Add Docker Files djangoToolkit.addDocker
Select Python Interpreter... djangoToolkit.selectPython
Open Django Documentation djangoToolkit.openDocs
Refresh Project Explorer djangoToolkit.refresh

Snippets

134 snippets for Python and Django templates. All prefixes start with dj: type dj to see the list.

Area Examples
Models djmodel, djchar, djfk, djm2m, djchoices, djmeta, djqs
Queries djq, djf, djannotate, djselect, djatomic
Views djview, djlv, djdv, djcv, djuv, djdelv, djtv, djfv, djqsm, djjson
URLs djurl, djurlcbv, djinclude, djurls
Forms and admin djmodelform, djcleanfield, djformset, djadmin, djinline
Infrastructure djsignal, djmw, djcmd, djtag, djuser, djsettings-*
Tests djtest, djtestview, djtestlogin, djtestapi
REST framework djser, djvs, djrouter, djapiview, djfilterset
Templates djextends, djblock, djfor, djif, djurlt, djstatic, djform, djpaginator, djbase

Template snippets work in django-html and html files.

Settings

Setting Default Description
djangoToolkit.pythonPath empty Python interpreter used to run manage.py. Leave empty to auto-detect .venv, venv or env next to the project, then the Python extension's interpreter, then python3/python.
djangoToolkit.managePyPath empty Path to manage.py (absolute, or relative to the workspace folder). Leave empty to auto-detect.
djangoToolkit.settingsModule empty Sets DJANGO_SETTINGS_MODULE for terminals opened by the extension, for example config.settings.dev.
djangoToolkit.serverAddress "127.0.0.1" Address the development server listens on.
djangoToolkit.serverPort 8000 Port the development server listens on.
djangoToolkit.showStatusBar true Show the Django server button in the status bar.
djangoToolkit.autoRegisterApps true After creating an app or scaffolding, add it to INSTALLED_APPS and include its URLs in the root urls.py.
djangoToolkit.scaffold.requireLogin false Generated CRUD views use LoginRequiredMixin.
djangoToolkit.scaffold.generateTests true Generate basic view tests when scaffolding.
djangoToolkit.scaffold.search true Add a search box to generated list pages (searches text fields).
djangoToolkit.openDelayMs 2500 Milliseconds to wait for the server to start before opening a page in the browser.

Troubleshooting

Problem What to do
"No Django project found" Open the folder containing manage.py, or set djangoToolkit.managePyPath.
Commands fail with "No module named django" Run Django: Select Python Interpreter... and pick the python inside your .venv.
404 on /articles/ while the admin works Your app is included under a prefix. Open Django: Open Root urls.py: with path('blog/', include('blog.urls')) the page is /blog/articles/.
404 on / (site root) Expected until you add a home page (Scenario 3).
404 on a page right after scaffolding Run Django: Diagnose Project; it checks that the app is installed and included.
A new app does not appear in the sidebar Click the refresh icon, or run Django: Refresh Project Explorer.
settings.py was not updated Add the app to INSTALLED_APPS yourself; the Django Toolkit output channel explains why.
ImageField error when migrating Install Pillow: pip install pillow.
"no such table" in the browser Run Django: Make Migrations, then Django: Migrate.
Scaffold says the model already exists Nothing was changed. Choose another model name.
The browser opened before the server was ready Refresh the page, or raise djangoToolkit.openDelayMs.

Good to know

  • Scaffolding never overwrites existing code. Existing files get new blocks appended and imports merged. If a class already exists, that file is skipped, and if the model already exists nothing is changed.
  • Scaffolding creates new models; it does not rewrite the fields of existing ones. Edit those in models.py, then run Make Migrations.
  • Generated templates are intentionally plain so you can restyle them.
  • The extension only writes inside your project folder (or the new project folder you choose). It has no telemetry and makes no network requests of its own; pip, which it runs when you ask for packages, downloads them from PyPI.

Requirements

  • VS Code 1.75 or newer
  • Python 3.10 or newer with pip (the extension uses the project's virtual environment when it finds one)
  • Django is installed by the project wizard, or install it yourself in your environment

Feedback

Issues and ideas: https://github.com/tirotir-ir/django-toolkit/issues

Happy coding with Django!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft