0% found this document useful (0 votes)
8 views54 pages

final vac

This document outlines a value-added course on Fullstack Web Development using Django for the academic year 2024-2025 at Einstein College of Engineering. It includes a detailed manual with a series of experiments for third-year Computer Science and Engineering students, covering topics such as creating virtual environments, installing Django, and building web applications. Each experiment is accompanied by aims, commands, and results, providing a comprehensive guide for students to learn and implement Django effectively.

Uploaded by

muthuram603
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views54 pages

final vac

This document outlines a value-added course on Fullstack Web Development using Django for the academic year 2024-2025 at Einstein College of Engineering. It includes a detailed manual with a series of experiments for third-year Computer Science and Engineering students, covering topics such as creating virtual environments, installing Django, and building web applications. Each experiment is accompanied by aims, commands, and results, providing a comprehensive guide for students to learn and implement Django effectively.

Uploaded by

muthuram603
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

EINSTEIN

COLLEGE OF ENGINEERING

SIR C.V. RAMAN NAGAR, TIRUNELVELI-627012

COMPUTER SCIENCE AND ENGINEERING


VALUE ADDED COURSE
ACADEMIC YEAR: 2024-2025 (REGULATION-2021)

FULLSTACK WEB DEVELOPMENT USING DJANGO

IIIrd year CSE-B

TEAM MEMBERS :

V.MUTHURAM - 950622104066

A.STEWAK GOLD RAJ -950622104105

A.PRAVEEN -950622104078

S.RATHNA PRAKASH - 950622104089


EINSTEIN
COLLEGE OF ENGINEERING
SIR C.V. RAMAN NAGAR, TIRUNELVELI-627012

COMPUTER SCIENCE AND ENGINEERING


VALUE ADDED COURSE
MANUAL
ACADEMIC YEAR: 2024-2025 (REGULATION-2021)

FULLSTACK WEB DEVELOPMENT USING DJANGO

IIIrd year CSE-B

Staff sign :…………………………………………..


INDEX

SNO DATE NAME OF THE EXPERIMENT PAGE SIGN

1 14-08-24 HOW TO CREATE VIRTUAL


ENVIRONMENT 3

2 21-08-24 HOW TO CREATE DJANGO AND


CREATE PROJECT 5

3 28-08-24 HOW TO CREATE FIRST DJANGO


APPLICATION 7

4 04-09-24 HOW TO RENDERING HTML FILE


9

5 11-09-24 HOW TO USE STATIC FILE WITH


DJANGO 15

6 18-09-24 INPUT OUTPUT FORM DESIGN


18

7 21-09-24 HOW TO USE GET AND BOST


METHOD IN DJANGO 23

8 05-10-24 HOW TO USE BOOTSTRAP FILE IN


DJANGO 29

9 09-10-24 DATABASE CREATION


32

10 23-10-24 SUPER USE CREATION


38

11 30-10-24 REGISTRATION FORM CREATION


39

12 06-11-24 REGISTRATION FORM


MANIPULATION (UPDATE AND 43
DELETE)
DATE :14.08.2024 HOW TO CREATE VIRTUAL
EX.NO: 01 ENVIRONMENT

AIM:
To create virtual environment using django.

COMMANDS :
python --version
pip install django
python -m django --version
python –m venv django-venv
cd django-venv ( change directory)
cd scripts
activate

COMMENT PROMPT:
pip list
cd..
python -m pip install django
pip list
cd script
deactivate
VISUAL STUDIO :
Goto new folder and django -venu
Create a file
Give name of the file as .py
POWER SHELL:
Get-Executionpolicy -List
Set-Executionpolicy unrestricted
Get-Executionpolicy -List
VISUAL STUDIO:
Go to terminal
Click “new terminal”
In terminal , enter “cd scripts “, “activate”

Result:
Thus the Django virtual environment successfully created.
DATE :21.08.2024 HOW TO INSTALL DJANGO AND
EX.NO: 02 CREATE PROJECT

AIM:
To install Django and create project.

COMMENT PROMPT:
Python -m venv django-venv
Cd django-venv
Cd scripts
activate
pip install django
cd..
dijango-admin –version
dijango-admin startproject new

VISUAL STUDIO:
Open folder Django-venv
Open terminal
Cd new
Python manage.py runserver
Copy the path and paste in the browser
Result:
Thus the Django was installed and Django project page
successfully created.
DATE :28.08.2024 HOW TO CREATE FIRST DJANGO
EX.NO: 03 APPLICATION

AIM:
To create first Django application.

VISUAL STUDIO CODE:


Open folder Django-venv
Cd new
Python manage.py startapp My_application
Open Settings.py
Installed_Apps= ‘ My_application’
Open Terminal
Cd new
Python manage.py runserver
Copy the path and paste in the browser

My_Application – Views.py
from django.shortcuts import render
from django.http import HttpResponse
def home(request):
msg="<h1> Welcome to Django </h1>"
return HttpResponse(msg)
def index(request):
return HttpResponse("<h1> This is Index </h1>")
New – url.py
from django.contrib import admin
from django.urls import path
from My_application import views
urlpatterns = [
path('admin/', admin.site.urls),
path('',views.home),
path('Home/',views.home),
path('Index/',views.index),
]
Press ctrl+s
➢ In terminal, enter (python manage.py runserver)
➢ Copy the path and paste it in brower

Result:
Thus the Django application page was created successfully
created.
DATE :04.09.2024 How to Rendering HTML
EX.NO: 04 Files

AIM:
To create rendering HTML files.
VISUAL STUDIO CODE:
New - create new folder (template) – create file (home.html)
<html>
<head>
<title> Einstein</title>
</head>
<body>
<h1> Wlcome to Einstein College</h1>
</body>
</html>
In setting.py
from pathlib import Path
import os
TEMPLATES = [
{ BACKEND':
'django.template.backends.django.DjangoTemplates', 'DIRS':
[os.path.join(BASE_DIR,"Template")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messa
ges',
],
},
},
]
Views.py
from pathlib import Path
import os
BASE_DIR = Path(__file__).resolve().parent.parent
def h(request):
result = os.path.join(BASE_DIR,"Template")
print(result)
return render(request, 'home.html')

change the msg to “Welcome to einstein college”

➢ Enter “python manage.py runserver”


➢ Copy the path and paste in browser
output:

Views.py
def h(request):
result = os.path.join(BASE_DIR,"Template")
print(result)
return render(request, 'home.html',{'Name':Amigo'})
Home.html
<html>
<head>
<title> Einstein</title>
</head>
<body>
<h1> Welcome {{Name}}</h1>
</body>
</html>
URLs.py ,
urlpatterns = [
path('admin/', admin.site.urls),
path('',views.h),
path('Home/',views.home),
path('Index/',views.index), ]
➢ Go to terminal, “cd new” “python manage.py runserver”
➢ Copy the path and paste it in browser.

Welcome da Mapla

In home.html ,
<html>
<head>
<title> home </title>
<style>
body {background-color:pink;}
h1 {color:blue;}
p {color:red;}
</style>
</head>
<body>
<center>
<h1> Welcome {{Name}}</h1>
<h2> Welcome {{Name}}</h2>
<h3> Welcome {{Name}}</h3>
<p>

Priyanka Mohan is such a delightful presence on screen! Her


performances in films like "Doctor" and "Don" have won her
a lot of fans. She has this natural charm and grace that makes
her stand out. Plus, her doe-eyed innocence and effortless
acting make her a favorite among directors and audiences
alike
Thank you for letting me share
</p>
</center>
</body>
</html>

Selva
Welcome Amigo
Welcome Amigo

Welcome Amigo

Priyanka Mohan is such a delightful presence on screen! Her performances in films like "Doctor" and "Don" have won her a lot of fans. She has this natural charm and grace that makes her stand out. Plus,
her doe-eyed innocence and effortless acting make her a favorite among directors and audiences alike

Result:
Thus to Rendering html Files successfully executed.
DATE :11.09.2024 HOW TO USE STATIC FILE WITH
EX.NO: 05 DJANGO

AIM:
To get input form using Django.

VS CODE
1. In home.html ,
<html>
<head>
<title>
Home
</title>
{%load static %}
<link rel="stylesheet" href="{%static 'css/style.css'%}">
</head>
<body>
<center>
<h1> Static Files</h1>
</center>
<img src="{% static 'image/1.jpeg' %}">
<img src="{% static 'image/2.jpeg' %}">
<img src="{% static 'image/3.jpeg' %}">
</body>

</html>
2. In urls.py ,
from django.contrib import admin
from django.urls import path
from My_application import views
urlpatterns = [ path('admin/', admin.site.urls),
path('',views.h),
]
3. In static,
create a file “static.css”,
img
{
height:350px;
width:350px;
margin-top:50px;
margin-left:100px;
box-shadow:5px 5px 15px ipx black;
border-radius:20px;
}
h1
{
margin-top:50px;
color:rgb(3,83,148);
}
4. In views.py
from django.shortcuts import render
from django.http import HttpResponse
from pathlib import Path import os
BASE_DIR = Path(__file__).resolve().parent.parent
def h(request):
return render(request, 'home.html')
5. In settings.py ,
STATIC_URL = 'static/'
STATICFILES_DIRS=[BASE_DIR/"static",]
6. Go to terminal and paste the path

Result:
Thus the use static file with Django successfully created.
DATE :18.09.2024 INPUT OUTPUT FORM DESIGN
EX.NO: 06

AIM:
To create INPUT OUTPUT FORM DESIGN using
django.

1. In home.html,
<html>
<head>
<title>
Home
</title>
{%load static %}
<link rel="stylesheet" href="{%static 'css/style.css'%}">
</head>
<body>
{%block content%}
<form action ="product" autocomplete="off">
<center>
<h1> PRODUCT</h1>
<h5>
MOBILE <input type="text" name="mobile ">
<br><br>
KEYBOARD <input type="text"
name="keyboard"> <br><br>
MONITOR <input type="text" name="monitor
"> <br><br>
<input type="submit" value="SUBMIT">
</h5>
</center>
</form>
{%endblock%}
</body>
</html>
2. In template,
create result.html file,
<html>
{%load static %}
<link rel="stylesheet" href="{%static 'css/style.css'%}">
<head>
<title>Result</title>
</head>
<body>
<center><h2>PRICE:{{price}}</h2></center>
</body>
</html>
3. In views.py,
from django.shortcuts import render
from django.http import HttpResponse
from pathlib import Path
import os
BASE_DIR = Path(_file_).resolve().parent.parent
def h(request):
return render(request, 'home.html')
def product(request):
mobile= int(request.GET["mobile"])
keyboard= int(request.GET["keyboard"])
monitor= int(request.GET["monitor"])
price=mobile+monitor+keyboard
return render(request,’result.html’,{"price":price})

4. In style.css,
h1
{
margin-top:50px;
color:rgb(184, 15, 15);
}
h2
{
margin-top: 400px;
color:rgb(27, 72, 88)
}
h5
{
margin-top: 150px;
line-height: 3;
color:rgb(27, 72, 88)
}
body
{
background-color:rgb(222, 214, 220)
}

5. In urls.py,
from django.contrib import admin
from django.urls import path
from My_application import views
urlpatterns = [
path('',views.h),
path('product',views.product) ]
6. Go to terminal ,
Cd new
Python manage.py runserver

7. Follow link,

Result:
Thus the input out from design successfully created.
DATE :21.09.2024 HOW TO USE GET AND BOST
EX.NO: 07 METHOD IN DJANGO

AIM:
TO USE GET AND BOST METHOD IN DJANGO
1. In URLS.PY,

2. In VIEWS.PY,
3. In HOME.HTML,
<html>
<head>
<title> Home </title>
<style>
table,th,td{
border:1px solid black;
border-collapse: collapse;
padding: 10px;
}
th,td{
padding: 10px;
6}
th{
text-align: right;
}
center{
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
}
</style>
</head>
<body>
{%block content%}
<form action="register" method="GET">
{%csrf_token%}
<table class="center">
<tr>
<th colspan="2">
<center><h3> REGISTRATION
</h3></th></center>
</tr>
<tr>
<th> Name </th>
<td> <input type="text" name="name"></td>
</tr>
<tr>
<th> Password </th>
<td> <input type="password"
name="Password"></td>
</tr>
<tr>
<th> ADDRESS </th>
<td> <input type="text"
name="address"></td>
</tr>
<tr>
<th> Mail </th>
<td> <input type="text" name="mail"></td>
</tr>
<tr>
<td colspan="2">
<center><input type="submit"
value="submit"></center>
</td>
</tr>
</table>
</form>
{%endblock%}
</body>
</html>

4. Create a new file called output.html


<html>
<head>
<title> OUTPUT </title>
<style>
table,th,td{
border: 1px solid black;
border-collapse: collapse;
padding: 10px;
}
th,td{
padding: 10px;
}
th{
text-align: right;
}
.center{
position: absolute;
top:50%;
left: 50%;
transform: translate(-50%,-50%);
}
</style>
</head>
<body>
{%block conten%}
<form>
<table class="center">
<tr>
<th colspan="2">
<center><h3> VIEW DETAILS
</h3></center>
</th>
</tr>
<tr>
<th> Name </th>
<td> {{Name}} </td>
</tr>
<tr>
<th> Password </th>
<td> {{password}} </td>
</tr>
<tr>
<th> ADDRESS </th>
<td> {{address}} </td>
</tr>
<tr>
<th> mail</th>
<td> {{mail}} </td>
</tr>
</table>
{%endblock%}
</body>
</html>

5. Go to terminal ,
Cd new
Python manage.py runserver

6. Follow link,

Result:
Thus the Django virtual environment successfully created.
DATE :5.10.2024 HOW TO USE BOOTSTRAP FILE IN
EX.NO: 08 DJANGO

AIM:

To use bootsrap file in django


STEPS:
Go to chrome and type www.getbootstrap.com

Click version 3.4-download bootstrap

Extract the zip file

Click the extracted folder and copy the folder and

rename the folder as bootstrap

Paste it in static which is inside the django-venv

To go to Static: Django-venv->new->static

In views.py ,
1. In home.html ,

2. In urls.py ,

3. In style.css ,
4. Go to terminal ,
Cd new
Python manage.py runserver

5. Follow link,

Result:
Thus to creation data base successfully created.
DATE :9.10.2024 DATABASE CREATION
EX.NO: 09

AIM:
To create data base creation using django.

1. To go to My_application

2. In HOME.HTML
<html>
<head>
<title> Register </title>
{% load static %}
<link rel="stylesheet" href="{% static
'bootstrap/css/bootstrap.min.css'%}">
</head>
<body>
<div class="container">
<div class="col-md-offset-3 col-md-5">
<form action="" method="post"
autocomplete="off">
{% csrf_tokens %}
<h3 class="page-header text-primary text-
center"> Registration </h3>
<div class="form-group">
<label> Name </label>
<input type="text" class="form-control"
name="name">
</div>
<div class="form-group">
<label> Age </label>
<input type="text" class="form-control"
name="age">
</div>
<div class="form-group">
<label> Address </label>
<input type="text" class="form-control"
name="address">
</div>
<div class="form-group">
<label> contact </label>
<input type="text" class="form-control"
name="contact">
</div>
<div class="form-group">
<label> Mail-id </label>
<input type="text" class="form-control"
name="mail">
</div>
<div class="form-group pull-right">
<input type="submit" value="Register"
class="btn btn-primary">
<input type="reset" value="Clear"
class="btn btn-danger">
</div>
</form>
</div>
</div>
</body>
</html>
3. In ADMIN.PY
4. In VIEWS.PY

5. In URLS.PY

6. Download sqlite

7. In vscode ,
cd new

python manage.py makemigrations My_application

python manage.py migrate

8.Open sqlite software-> open database->click django-


venv folder->click->new
->click db.sqlite3->select open
9. Go to browse data and check if it is empty and run the
program.
10. Follow link,

11. click register .


12. In db sqlite and check browse data

Result:
Thus the Django Database creation successfully created.
DATE :30.10.2024 SUPER USER CREATION
EX.NO: 10

AIM:
To create super user creation using django.
1. In Terminal,
run the server next new terminal,
Password is : muthuram2004

muthuram

Result:
Thus the Django super user creation successfully created.
DATE REGISTRATION FORM CREATION
:9.10.2024
EX.NO: 09

AIM:
To create registration form creation using django.
1. In Chrome,
localhost:8000/admin/

2. Type user name and password.

3. Click datas and click any one of the object.


4. In views.py,

5. In urls.py ,
6. In home.html,

<div class="col-md-6">
{% if datas %}
<h3 class="page-header text-primary text-center">
View details</h3>
<table class="table table-bordered">
<thead>
<tr>
<th>SI.No</th>
<th>Name</th>
<th>Age</th>
<th>Address</th>
<th>Contact</th>
<th>E-mail</th>
</tr>
</thead>
{% for data in datas %}
<tbody>
<tr>
<td>{{forloop.counter}}</td>
<td>{{data.Name}}</td>
<td>{{data.Age}}</td>
<td>{{data.Address}}</td>
<td>{{data.Contact}}</td>
<td>{{forloop.mail}}</td>
</tr>
</tbody>
{% endfor %}
</table>
{% endif %}

NOTE: Do not change anything in models.py

7. Run the program,


Result:
Thus the Django registration form creation successfully
created.
DATE :6.11.2024 REGISTRATION
EX.NO: 12 FORMMANIPULATION( UPDATE
AND DELETE )

AIM:
To create registration form manipulatin using django.
1. In Views.py,
from django.shortcuts import render,redirect
from django.http import HttpResponse
from .models import Datas
def hh(request):
mydata=Datas.objects.all()
if(mydata!=''):
return render(request,'home.html',{'datas':mydata})
else:
return render(request,'home.html')
def addData(request):
if request.method=='POST':
name=request.POST['name']
age=request.POST['age']
address=request.POST['address']
contact=request.POST['contact']
mail=request.POST['mail']
obj=Datas()
obj.Name=name
obj.Age=age
obj.Address=address
obj.Contact=contact
obj.Mail=mail
obj.save()
mydata=Datas.objects.all()
return redirect('home')
return render(request,'home.html')
def updateData(request,id):
mydata=Datas.objects.get(id=id)
print(mydata)
if request.method=='POST':
name=request.POST['name']
age=request.POST['age']
address=request.POST['address']
contact=request.POST['contact']
mail=request.POST['mail']
mydata.Name=name
mydata.Age=age
mydata.Address=address
mydata.Contact=contact
mydata.Mail=mail
mydata.save()
return redirect('home')
return render(request,'update.html',{'data':mydata})
def deleteData(request,id):
mydata=Datas.objects.get(id=id)
mydata.delete()
return redirect('home')

2. In template,
create new file and give name as update.html

<html>
<head>
<title> Register </title>
{% load static %}
<link rel="stylesheet" href="{% static
'bootstrap/css/bootstrap.min.css' %}">
</head>
<body>
<div class="container-fluid">
<div class="col-md-offset-4 col-md-4">
<form action="/updateDate/{{data.id}}"
method="post" autocomplete="off">
{% csrf_token %}
<h3 class="page-header text-primary text-
center"> Registration </h3>
<div class="form-group">
<label>Name</label>
<input type="text" class="form-control"
value="{{data.Name}}" name="name">
</div>
<div class="form-group">
<label>Age</label>
<input type="text" class="form-control"
value="{{data.Age}}" name="age">
</div>
<div class="form-group">
<label>Address</label>
<input type="text" class="form-control"
value="{{data.Address}}" name="address">
</div>
<div class="form-group">
<label>Contact</label>
<input type="text" class="form-control"
value="{{date.contact}}" name="contact">
</div>
<div class="form-group">
<label>Mail-id</label>
<input type="text" class="form-control"
value="{{date.Mail}}" name="mail">
</div>
<div class="form-group pull-right">
<input type="submit" value="update"
class="btn btn-primary btn-block">
</div>
</form>
</div>
</div>
</body>
</html>

3. In Home.html
<html>
<head>
<title> Register </title>
{% load static %}
<link rel="stylesheet" href="{% static
'bootstrap/css/bootstrap.min.css'%}">
</head>
<body>
<div class="container-fluid">
<div class="col-md-offset-1 col-md-4">
<form action="addData" method="post"
autocomplete="off">
{% csrf_token %}
<h3 class="page-header text-primary text-
center"> Registration </h3>
<div class="form-group">
<label> Name </label>
<input type="text" class="form-control"
name="name">
</div>
<div class="form-group">
<label> Age </label>
<input type="text" class="form-control"
name="age">
</div>
<div class="form-group">
<label> Address </label>
<input type="text" class="form-control"
name="address">
</div>
<div class="form-group">
<label> contact </label>
<input type="text" class="form-control"
name="contact">
</div>
<div class="form-group">
<label> Mail-id </label>
<input type="text" class="form-control"
name="mail">
</div>
<div class="form-group pull-right">
<input type="submit" value="Register"
class="btn btn-primary">
<input type="reset" value="Clear" class="btn
btn-danger">
</div>
</form>
</div>
<div class="col-md-6">
{% if datas %}
<h3 class="page-header text-primary text-center">
View details</h3>
<table class="table table-bordered">
<thead>
<tr>
<th>SI.No</th>
<th>Name</th>
<th>Age</th>
<th>Address</th>
<th>Contact</th>
<th>E-mail</th>
<th>Update</th>
<th>Delete</th>
</tr>
</thead>
{% for data in datas %}
<tbody>
<tr>
<td>{{forloop.counter}}</td>
<td>{{data.Name}}</td>
<td>{{data.Age}}</td>
<td>{{data.Address}}</td>
<td>{{data.Contact}}</td>
<td>{{forloop.mail}}</td>
<td><a class="btn btn-success"
href="updateData/{{data.id}}">Update</a></td>
<td><a class="btn btn-danger"
href="deleteData/{{data.id}}">Delete</a></td>
</tr>
</tbody>
{% endfor %}
</table>
{% endif %}
</div>
</div>
</body>
</html>

4. In Urls.py
from django.contrib import admin
from django.urls import path
from My_application import views
urlpatterns = [
path('admin/',admin.site.urls),
path('',views.hh,name="home"),
path('addData',views.addData,name="addData"),
path('updateData/<int:id>',views.updateData,name="update
Date"),
path('deleteData/<int:id>',views.deleteData,name="deleteD
ata"),
]
5. Run the program.

Result:
Thus the Django registration form manipulation
successfully created.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy