pip install django # Installs Django globallypipenv install django # Installs Django in the project folderCreate a virtual environment named env using Python and activate it in the current PowerShell session.
python -m venv env
env\Scripts\activate-
Install
pipenv:pip install pipenv
-
Verify installation:
pip show pipenv pipenv --version
-
Activate the virtual environment:
pipenv shell
-
View available Django admin commands:
django-admin
-
Start a new Django project:
django-admin startproject storefront . -
Run the Django project:
python manage.py runserver # Runs on the default port (8000) python manage.py runserver 7000 # Runs on a custom port (7000)
-
Find the virtual environment path:
pipenv --venv
-
Copy the path and append
\Scripts\python.exe(e.g.,C:\Users\charith\.virtualenvs\storefront-JshKXDAk\Scripts\python.exe). -
Set the Python interpreter in VS Code:
- Press
Ctrl + P. - Search for
Python: Select Interpreter. - Choose
Enter Interpreter Pathand paste the path.
- Press
- Open terminal: Ctrl + ` or J
- Clear terminal: Ctrl + L
-
Create a new app:
python manage.py startapp playground
-
Key files and their purposes:
migrations/: Tracks and applies database migrations (e.g., generating database tables).admin.py: Customizes the Django admin interface.apps.py: Configures the app.models.py: Defines model classes to interact with the database.views.py: Handles requests and returns responses.