I am a beginner programmer who was trying to create his first project in VS Code. I installed in the Windows Powershell Django and activated a virtual environment as followed through the following pages:
And also tried to install it on VS Code directly following this tutorial on YT:
https://www.youtube.com/watch?v=Wfu5dPbiyKA
however, the following problems occur when I check the files in VS Code
wsgi.py:
from django.core.wsgi import get_wsgi_application
This line throws the following warning:
Import "django.core.wsgi" could not be resolved from source
and the same error is thrown in the urls.py file and asgi.py file for the following:
Asgi: from django.core.asgi import get_asgi_application
Urls:
from django.contrib import admin
from django.urls import path
After some research, I discovered that either I installed incorrectly Django into my computer or VS Code, or either I can install them individually. However, neither have worked as when I try to check the status of Django, it says that the module doesn't exist. Please help, thanks.
So following https://docs.djangoproject.com/en/4.2/howto/windows/ you should have Python installed, created a virtual environment, entered the environment with ...\> project-name\Scripts\activate.bat
and then installed django with pip install django
.
After this, you should be able to use the django-admin --version
command in your terminal.
After this is working, you can start a django project following the official tutorial: https://docs.djangoproject.com/en/4.2/intro/tutorial01/
Create the project with django-admin startproject projectname
and start the server with python manage.py runserver
.
VS Code should have nothing to do with that. You can also use the terminal inside VS Code to run all the commands, but I would recommand using the original windows terminal for the start - just to be sure its working.