Django shows error when trying to run the server

I have been facing issues in using Django. Actually when I tried to run the command :-

python runserver

It gives me an error that Django is not installed or I’ve not activated the virtual environment (When I’ve done it already). Even at this moment inside the file, there’s an error from line 11 that says :-


Here it’s showing an error that Django isn’t installed.
I’m quite confused and some assistance will be helpful.

make sure you installed django inside your Virtual environment and not globally in your PC.
type pip list in terminal and check if its installed.

make sure this line has your project name correct.
in line 9
instead of YOUR_APP insert your app name.

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'YOUR_APP.settings')

Thanks for your assistance in that. I fixed that error a couple of hours ago. But I need to know if we always need the virtual environment to be activated?
Because whenever I’m trying to execute this code " env/scripts/activate", it shows the error that the Windows PowerShell blocks scripts to be executed in the PowerShell terminal. And I can’t figure out how to get past that.

1 Like

It’s always the best to use Virtual Environment because you will get a lot of errors if you not use one,
because Each project has it’s packages, and will be a big conflicts without Virtual Env.

for sorrow i am a linux guy, but i can search for it with you.
make sure you type this command inside your Virtual Env.

i guess your problem that your powershell disabled running scripts for security, you can follow this guide to enable it.

Thanks for the guidance. This means a lot.
Finally, this worked and now I can properly work on the Django projects here