Django shows error when trying to run the manage.py server

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

python manage.py 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 manage.py file, there’s an error from line 11 that says :-

from django.core.management

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 manage.py line 9
instead of YOUR_APP insert your app name.

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

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.

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

https://winbuzzer.com/2020/07/10/how-to-enable-powershell-scripts-in-windows-10-via-powershell-execution-policy-xcxwbt/

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

1 Like