Steps to develop Django with VSCode

2020/03/13 Slightly modified to match VSCode Version 1.43.0

Introduction

Beginners longed for the word debug, and learned that VS Code can actually do it, so I set it up. The memorandum. I think the advantage is that once you set it up, you can just press the Debug button to enter the virtual environment and run the server. You can save yourself the trouble of typing source myenv / bin / activate or python manage.py run server back and forth between your browser, Terminal and VS Code. A little easier.

Reference URL

Django Tutorial in Visual Studio Code

environment

Ubuntu 18.04 LTS Python 3.6.9 Django 2.2.8 or 3.0

Steps to develop Django with VSCode

Preparation at Terminal

$ mkdir myproject
$ cd myproject
$ python3 -m venv myenv
        #It seems that there are various virtual environments, but here you can choose venv.
$ source myenv/bin/activate
        #I put it in a virtual environment.The prompt in the virtual environment is as follows(myenv)$To.
(myenv)$ pip install django
        #Django is installed(Django to specify version==2.2.Enter as 8)
(myenv)$ django-admin startproject config .
        #Finally the project started.The name is config.The reason is from the "Django textbooks that can be used in the field" book.
        #Last".Don't forget.If you don't add it, you will have more directories, which is a little troublesome..
(myenv)$ deactivate
        #Exit the virtual environment once

The current directory structure is as follows

.
├── config
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── manage.py
└── myenv

Prepare the development environment with VS Code

  1. Start VSCode and click Open Folder ... from File to open the myproject directory. startscene.png

  2. Install Python Extention selectextention.JPG

  3. Select Command Palette ... in View and click Python: select interpreter commandpalette.JPG

  4. Select the interpreter for the virtual environment (myvenv in this case) afterselectpython.JPG

  5. Click the bug icon on the far left, then click the gear icon and select Python

  1. Select Django from the view beforerunserver.JPG

  2. DEBUG Press the green triangle button on the right to automatically run server finalscene.JPG

  3. Fly to 127.0.0.1:8000 with a web browser and launch the usual rocket startscreen.png

This saves you the trouble of launching multiple Terminals, selling commands each time, and going back and forth between windows. Convenient. I realized that VS Code is not just an editor, but a development environment, which is amazing.

The problem is ... ** beginners don't know what to do with debugging **.

Recommended Posts

Steps to develop Django with VSCode
How to develop a cart app with Django
Steps to create a Django project
Common html to rent with Django
How to get started with Django
How to authenticate with Django Part 2
How to authenticate with Django Part 3
How to do arithmetic with Django template
Step notes to get started with django
[5 steps] Apply anaconda virtual environment to VScode
Internationalization with django
CRUD with Django
Steps to build a Django environment with Win10 WSL Ubuntu18.04 + Anaconda + Apache2
The easiest way to get started with Django
Steps to develop a web application in Python
How to implement "named_scope" of RubyOnRails with Django
Steps to create a Twitter bot with python
Steps to install your own library with pip
Authenticate Google with Django
Django 1.11 started with Python3.6
Upload files with Django
Development digest with Django
I tried to create a table only with Django
Output PDF with Django
Let's develop something close to embedded with TDD ~ Preparation ~
Markdown output with Django
Convert 202003 to 2020-03 with pandas
Steps from installing Django to displaying an html page
Use Gentelella with django
(Python) Try to develop a web application using Django
Twitter OAuth with Django
Getting Started with Django 1
When you want to filter with Django REST framework
Send email with Django
Steps from installing Python 3 to creating a Django app
File upload with django
unable to import django
Use LESS with Django
Single sign-on to your Django application with AWS SSO
Pooling mechanize with Django
Transit to the update screen with the Django a tag
Things to do when you start developing with Django
Use MySQL with Django
Things to watch out for when migrating with Django
update django version 1.11.1 to 2.2
Ssh to virtual environment with remote development of vscode
Model.objects.extra to consider before using raw SQL with Django
Start today with Django
Getting Started with Django 2
Let's develop something close to embedded with TDD ~ Intermediate review ~
It's too easy to use an existing database with Django
How to handle static files when deploying to production with Django
Let's develop something close to embedded with TDD ~ Problem raising ~
Recommendations for django, wagtail ~ Why develop a website with python ~
How to check ORM behavior in one file with django
I want to make a blog editor with django admin
Steps to learn & infer transformer English-Japanese translation model with CloudTPU
Steps to install a Git cloned package locally with pip
[Django] How to give input values in advance with ModelForm
How to resolve CSRF Protection when using AngularJS with Django
I'm trying to create an authentication / authorization process with Django