I am brand new to Django and I’m trying to follow an on-line tutorial. I’m working on Windows 10 and installed everything that I was asked to - I think, but I don’t see Django modules when creating code in Visual Studio. There are not a whole lot of modules listed. I found one, django-urls that I installed, but that’s about it. Do I have to install each django module by hand?
This is my environment:
Windows 10
Python 3.8.6
pip 20.2.1
virtualenvwrapper-win 1.2.6
virtualenv 20.0.32
(In Virtual Environment) Django 3.1.2
Visual Studio 16.7.5
Just about everything is missing:
unresolved import ‘django.shortcuts’
unresolved import ‘django.http’
unresolved import ‘django.contrib’
etc.
Results from a “pip freeze” command in the virtual environment:
asgiref==3.2.10
Django==3.1.2
django-urls==1.1.3
pytz==2020.1
sqlparse==0.3.1
This error messages are from VSCode. I think it’s not recognizing your python virtualenv, which is where you installed Django. You must select the Python interpreter.
I recommend you to make the Django tutorial from VSCode, as it shows interesting features to work with Django projects.
It might be an issue with configuring VisualStudio. When I go directly to my virtual environment and run Python, the interpreter seems to find everything. Unfortunately I am a newbee with VS also and I’m not sure how to set that up.
From stand alone Windows Command Prompt:
Q:>lsvirtualenv
dir /b /ad “C:\Users\em817m\Envs”
frontdoortest
Q:>workon frontdoortest
(frontdoortest) Q:>python
Python 3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
from django.shortcuts import render
from django.http import HttpResponse
from django.urls import path, include
You can visit geeksforgeeks website for installing Django.
For video demonstration you visit codewithharry Youtube channel. It is pretty good. I personally follow this channel for learning Django.
All, thanks for all the suggestions. After watching many Visual Studio, Django and Virtual Environment videos I finally got things to work. I was able to create the django “Hello World” web page and display it, (the first app example in the “django For Beginners” video). The major change I implemented was using the python “venv” process to create my virtual environment and not the virtualenvwrapper-win that was suggested in the video. I’m not sure if that was the cause of my problems or not. All I know is that it worked.