...

Step-by-Step Guide to Installing Django on Windows 7

Learn how to seamlessly install and set up Django on Windows 7 with our comprehensive step-by-step guide. From installing Python and creating a virtual environment to configuring static files and setting up your first Django app, this tutorial covers everything you need to kickstart your Django development journey on Windows 7. Master the installation process and dive into Django development with ease.

Description:

Learn how to install Django on Windows 7 with our detailed guide. Follow step-by-step instructions to set up Python, create a virtual environment, install Django, and start your first Django project. Additionally, we'll cover managing dependencies, setting up the admin panel, configuring static and template files, and creating views and URL patterns for your first app. Get started with Django development on Windows 7 today!

Step 1: Install Python

Step 2: Open PowerShell and Verify Python Installation

Step 3: Upgrade Pip

Step 4: Create a Project Directory

Step 5: Create and Activate a Virtual Environment

Step 6: Install Django in the Virtual Environment

Step 7: Start a New Project and Add an App

Step 8: Run the Server

Step 9: Managing Dependencies with requirements.txt

Step 10: Check Django Version and Perform Migrations

Step 11: Set Up Admin Panel

Step 12: Configure Static and Template Files

Step 13: Create Views and URL Patterns for Your First App

Step 14: Test and Run Your Django Application


Django web CMD


# Installation
# sudo apt-get install python3-django# Check version 
# django-admin --version 
# Startproject 
# django-admin startproject projectname
# Then # Migrate cmd
# python3 manage.py migrate
# Admin panel
 # python3 manage.pp createsuperuser
# Then give admin password # Run server
#  python manage.py runserver# Win 10
# https://appuals.com/fix-pip-is-not-recognized-as-an-internal-or-external-command
# django in win 10 
# Then see thi video 
# https://www.youtube.com/watch?v=2FvIa4BADvA
# LOCAL HOST 
# Python -m http.server
# https://appuals.com/fix-pip-is-not-recognized-as-an-internal-or-external-command
/# django in win 10
ORDER TO INSTALL DJANGO WIN7

========================================================
Step 1
========================================================
install python on pc 
========================================================
Step 2
========================================================
Open Powershell
Verify Python Installation by
========================================================
python -V
========================================================
Step 3 - Upgrade Pip
========================================================
python -m pip install --upgrade pip
========================================================
Step 4 - Create a Project Directory by
========================================================
mkdir django_project
GOTO 
cd django_project
========================================================
Step 5 - Create Virtual Environment
========================================================
python -m venv venv
AND THIS 
pip install virtualenv
========================================================
Step 6 ASSIGN NAME 
========================================================
virtualenv venv
======================================================== 
NEXT Activate Virtual Environment by GOTO 
======================================================== 
venv\Scripts\activate
======================================================== 
Step 7 - Install Django IN V.env
========================================================
pip install django
========================================================
Step 8 - Start a New Project
========================================================
django-admin startproject testsite
go to 
cd testsite
========================================================
you can add app 
========================================================
python manage.py startapp myapp
========================================================
Step 9 - Run the Server by 
========================================================
python manage.py runserver
========================================================
for add new dependencey or pakages 
========================================================
pip freeze > requirements.txt
========================================================
then run server 
========================================================
python manage.py runserver
========================================================
========================================================
pip install -r requirements.txt
========================================================
Check version 
========================================================
django-admin --version 
========================================================
for migrations and  migration  
========================================================
python manage.py makemigrations
========================================================
if no changes detected  then type  
========================================================
python manage.py migrate
========================================================
Admin panel cmds 
========================================================
python manage.py createsuperuser
Then give admin password 
========================================================
 python manage.py runserver
========================================================
most important in django  important in django
important in django important in django
========================================================
1st required for folder 
open setting find templates add this below cmd==>
========================================================
'DIRS': [os.path.join(BASE_DIR,'templates')],
========================================================
2ND STATIC FOLDER FOR CSS JS AND PICS ETC 
========================================================
# Added manually

STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static") ]
======================================================

======================================================
3RD  thing is required  
======================================================

import os # new

i used then my static files problem solved 

python manage.py collectstatic
=======================================================

4th  in head tag add below 
=======================================================

{% load static %}
=======================================================

for style sheet in link tag add this 
=======================================================

<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}">
-----------------------------------------------------------------------


========================================
My first app with httprequest required 
========================================
1st open setting add app name 
========================================
INSTALLED_APPS['myapp']
========================================
2nd add in current urls
========================================
from django.urls import path,include
and 
 path('',include('myapp.urls'))
================================================================================
create new file in app view file then add
================================================================================
from django.shortcuts import render
from django.http import HttpResponse


# Create your views here.
def myfunctioncall(request):
return HttpResponse("<h1>hello world this is from my app</h1>")
================================================================================
app urls dir 

from django.urls import path
from . import views
urlpatterns=[
path('preet/',views.myfunctioncall,name='preet')

]
================================================================================
then run server with 
in url =>preet/

======================
add function app views 
=====================
def add(request,a,b):
# a=int(input("enter num1"))
# b=int(input("enter num2"))
return HttpResponse(f'<h1> You ans is :{a+b}</h1>')
=====================
in urls 
=====================
path('add/<int:a>/<int:b>',views.add,name='add'),

==========================================
Json response add this  in urls
==========================================
path('intro/<str:name>/<int:age>',views.intro,name='intro'),
==========================================
in views 
==========================================
from django.http import HttpResponse,JsonResponse
==========================================
Function is 
==========================================
def intro(request,name,age):
my_dict={
'Name':name,
'Age':age 
}

return JsonResponse(my_dict)
==========================================

William Anderson

I am a versatile Full-Stack Web Developer with a strong focus on Laravel, Livewire, Vue.js, and Tailwind CSS. With extensive experience in backend development, I specialize in building scalable, efficient, and high-performance web applications.