Load Django into Visual Studio Code and start your web server. If you don't have an editor, you'll have to run "python manage.py runserver" manually, With VSC, you can start the development WEb server with the touch of a button, which is convenient. It took a long time to set it, so make a note of it.
Click "Add Folder" from the Explorer screen at the top left.
Select a project folder. This is the project folder where you created Django with "django-admin startproject project name".
The workspace is now set up. Next, set up so that the development web server can be started. Next, open the debug screen with the bug icon on the left and press "Create launch json file". The folder name of the workspace is displayed above, so select it.
Then select the target environment. But unfortunately there is no "django" in the candidates.
You need to open the django file once. Open views.py and try again. Django is displayed as a candidate, so select it.
A launch.json has been created for Django.
Now that the settings are in place, let's start the development web server. Press the triangle mark on the upper left. If the bottom turns orange, you have started.
I will check it for the time being. The screen is displayed, so confirmation is OK.
① No such file or directory hogehoge manage.py As you can see in the error message, manage.py is missing. The workspace location is specified incorrectly. I used to specify the app folder as the workspace instead of the project folder.
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\work\\hogehoge\\manage.py'
② SyntaxError: invalid syntax The error and message look like this
File "C:\Users\hoge\anaconda3\lib\runpy.py", line 236, in _get_code_from_file
code = compile(f.read(), fname, 'exec')
File "c:\work\02_Implementation\hogehoge\.vscode\launch.json", line 2
//You can use IntelliSense to learn the available attributes.
^
SyntaxError: invalid syntax
The cause was that I chose python over Django when creating launch.json. Apparently you're trying to run launch.json in python? Seems to be the direct cause. Although it is in English, it is also described in stack overflow. There is.
If you specify Django as you did in the procedure and recreate launch.json, you can start it normally.
I was wondering if I could do it more quickly, but it took longer than I expected. If you go straight, it will take about 5 minutes.
Recommended Posts