Ive set up django on a virtual env and im trying to run it. I've made sure that python is installed and that my virtual env is activated. I created a django project "my_site" with the command django-admin startproject my_site . The virtual env is "my_env" This is my project directory: enter image description here In the command terminal when i run python migrate.py runserver nothing happens, the server crashes with no error message and i am not able to access localhost 8000
(my_env) PS C:\Users\Ananya\OneDrive\Desktop\django> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
(my_env) PS C:\Users\Ananya\OneDrive\Desktop\django>
This is the output for pip list :
(my_env) PS C:\Users\Ananya\OneDrive\Desktop\django> pip list
Package Version
------------------ -------
asgiref 3.7.2
backports.zoneinfo 0.2.1
Django 4.2.8
pip 20.2.3
setuptools 49.2.1
sqlparse 0.4.4
typing-extensions 4.9.0
tzdata 2023.4
WARNING: You are using pip version 20.2.3; however, version 23.3.2 is available.
You should consider upgrading via the 'c:\users\ananya\onedrive\desktop\django\my_env\scripts\python.exe -m pip install --upgrade pip' command.
(my_env) PS C:\Users\Ananya\OneDrive\Desktop\django>
This is the output for pip show Django :
(my_env) PS C:\Users\Ananya\OneDrive\Desktop\django> pip show django
Name: Django
Version: 4.2.8
Summary: A high-level Python web framework that encourages rapid development and clean, pragmatic design.
Home-page: https://www.djangoproject.com/
Author: Django Software Foundation
Author-email: [email protected]
License: BSD-3-Clause
Location: c:\users\ananya\onedrive\desktop\django\my_env\lib\site-packages
Requires: sqlparse, asgiref, backports.zoneinfo, tzdata
Required-by:
(my_env) PS C:\Users\Ananya\OneDrive\Desktop\django>
This is my python and django version
(my_env) PS C:\Users\Ananya\OneDrive\Desktop\django> python --version
Python 3.8.8
(my_env) PS C:\Users\Ananya\OneDrive\Desktop\django> python -m django --version
4.2.8
I tried running :
python C:\Users\Ananya\OneDrive\Desktop\django\manage.py runserver , I tried deleting and creating a new env . i was expecting the terminal output to be something like : image
where i can be directed to localhost 8000
Don't move folders manually in django projects. (unless your know what you are doing)
Your folder structure should be like this.
Your terminal should move in to "my_site" folder.
Run
Then run "migrations" and "runserver".
Only creat project command can run outside, All the other django commands should run inside your django project folder, where manage.py file is. Use
To change the terminal location.
So below is the normal procedure.
use
python manage.py runserver
or
python3 manage.py runserver