File
File
File
Training is an integral part of B.voc (software Development) and each and every student has to
undergo the training for 6 month in a company.
This record is concerned about our practical training during the Summer Vacations after the
3rd year We have taken our Practical training in During this training, we got to learn many new
things about the industry and the current requirements of companies. This training proved to
be a milestone in our knowledge of present industry. Every say and every moment was an
experience in itself, an experience which theoretical study can't provide.
To Whom It May Concern
It is certified that: Gursewak Singh S/O: Balwinder Singh student of class B.voc (Software
Development) semester: 6th bearing University Roll No. 903112 in session: 2023 is carried out his
six month training at Apptunix Mohali on the project on online shopping to fulfil the requirements
for the award of degree of "B.voc (Software Development)"Professor Rekha Kalra Head Of
Department Of Computer Science Guru Nanak College, Budhlada
(H.O.D)
Certificate of Originality
It is certified that the project report intitled online shopping submitted to Guru Nanak College
Budhlada affliated to Punjabi University Patiala in Partial fulfillment of the requirement for
the award of degree Bvoc (Software development) is original work carried out by Mr
Gursewak
Singh, Roll No.903112 respectively under my guidance The matter embedded in this project
genuin work done by the students and has not been submitted to this university or to any
university
institutes for the fulfillment of the requirement of any course of study.
Signature of Students
Signature of The Guide
Date:
I express my sincere gratitude to Mr. Narinder Singh Asst professor department of computer
science Guru Nanak College for her kind support and inspiration given to me till the end of my
project we thank Mrs REKHA KALARA head, department of computer science, Mr. Narinder Singh ,
principle ,Guru Nanak college for their constant support and encouragemet given throughout the
development of the project Training & Placement Incharge for providing me an opportunity to
undergo summer training at SOFTWIZ PVT LTD
I am thankful to Mr. ASHWINI for his support cooperation and motivation provided to me during
the training for constant inspiration presence and blessings
I also extend my sincere appreciation to Mr. ASHWINI who provided his valuable suggestions and
precious time in accomplishing my training report
Lastly, I would like to thank the almighty and my parents for their moral support and my friends
with whom I shared my day-to day experience and received lots of suggestions that my quality of
work.
• RAM - 256 MB
• DATABASE - Django4.2
PLATFORM USED
Windows
• Window derived from its name from the on-screen “WINDOWS” that it used
to display information’s.
• GUI makes it easy to work with disks and directories. It can display
tree like diagram of directories, sub-0 directories on hard disk.
• User friendly.
• Several programs at the same.
FRONT END USED
VISUAL STUDIO CODE
Introduction to Visual Studio Code
Visual Studio Code is a code editor in layman’s terms. Visual Studio Code is “a
free-editor that helps the programmer write code, helps in debugging and
corrects the code using the intelli-sense method ”. In normal terms, it
facilitates
users to write the code in an easy manner. Many people say that it is half of an
IDE and an editor, but the decision is up to to the coders. Any program/software
that we see or use works on the code that runs in the background. Traditionally
coding was used to do in the traditional editors or even in the basic editors like
notepad! These editors used to provide basic support to the coders.
Some of them were so basic that it was very difficult in writing basic English level
programs in them. As time went by, some programming languages needed a
specific framework and support for further coding and development it, which was
not possible using these editors. VI Editor, Sublime Text Editor, is one of the many
kinds of editors that came into existence. The most prominent and which
supports almost every coding language is VISUAL STUDIO CODE. Its features let
the user modify the editor as per the usage, which means the user is able to
download the libraries from the internet and integrate it with the code as per his
requirements.
What can Visual Studio Code do?
Visual Studio Code has some very unique features. They are listed as below :
Support for multiple programming languages: Supports multiple
programming languages. So earlier, programmers needed Web-Support:
a different editor for different languages, but it has built-in multi-
language support. This also means it easily detects if there’s any fault or
cross-
language reference, it’ll be able to detect it easily.
Intelli-Sense: It can detect if any snippet of code is left incomplete. Also,
common variable syntaxes and variable declarations are made
automatically. Ex: If a certain variable is being used in the program and
the user has forgotten to declare, intelli-sense will declare it for the user.
Cross-Platform Support: Traditionally, editors used to support
either Windows or Linux or Mac Systems. But Visual Studio Code is cross-
platform. So it can work on all three platforms. Also, the code works on all
three platforms; else, the open-source and proprietary software codes
used to be different.
Extensions and Support: Usually supports all the programming languages
but, if the user/programmer wants to use the programming language
which is not supported then, he can download the extension and use it.
And
performance-wise, the extension doesn’t slow down the editor as it rums
as a different process.
Repository: With the ever-increasing demand for the code, secure and
timely storage is equally important. It is connected with Git or can be
connected with any other repository for pulling or saving the
instances.
Web-Support: Comes with built-in support for Web applications. So
web applications can be built and supported in VSC.
Hierarchy Structure: The code files are located in files and folders. The
required code files also have some files, which may be required for
other complex projects. These files can be deleted as per convenience.
Improving Code: Some code snippets can be declared a bit
differently, which might help the user in the code. This function
prompts the user, wherever necessary, to change it to the suggested
option.
Terminal Support: Many of the times, the user needs to start from the
root of the directory to start with a particular action, in-built terminal or
console provides user support to not to switch in-between two screens for
the same.
Multi-Projects: Multiple projects containing multiple files/folders can
be opened simultaneously. These projects/folders might or might not
be
related to each other.
Git Support: Resources can be pulled from Git Hub Repo online and
vice- versa; saving can be done too. Resource pulling also means cloning
the code which is made available on the internet. This code can later be
changed and saved.
Commenting: A common feature, but some of the languages do
not support it. Commenting on the code helps the user to recall or
track according to the sequence he wants.
Advantages and Why should we use Visual Studio Code
There are many advantages over any other IDE; they are as follow:
1. Cross-platform support :
Windows
Linux
Mac
2. Light-weight
3. Robust Architecture
4. Intelli-Sense
5. Freeware: Free of Cost- probably the best feature of all for all the
programmers out there, even more for the organizations.
6. Many users will use it or might have used it for desktop applications only, but
it also provides great tool support for Web Technologies like; HTML, CSS, JSON.
There are a few things that one can find a bit odd compared with so many
features. It mainly helps the front-end developers as compared with the back-end
developers. But as per some user’s opinions, it is equally helpful. It supports most
of the languages used by most of the programmers, but other languages might
have to download, or extensions may have to be used for them. Along with this
common zoom-in, zoom-out brightness, theme selection features too are made
available.
Visual Studio Scope
The most common languages are :
C#
Visual Basic
Java-Script
R
XML
Python
CSS
GO
PERL
Another feature that naïve-users or anyone can see instantly different from
other editors is the user-friendliness of the Visual Studio Code. The usability is
very easy to handle. The file is arranged hierarchically and has regular software
like a
toolbar, status bar, and a sidebar. It also has a floating windows explorer window,
which can be fixed at one place according to convenience, which consists of the
directory structure of files. These files (code files, image folders, etc.) can be
opened or renamed from here, and changes will automatically get reflected in the
storage.
Why do we need Visual Studio Code?
Till recent times, there’s hardly been an IDE or code editor that has been so user-
friendly that even first-time users can use each and every feature without any
hassles. The coding-friendly feature and code error recognition also helps users a
long way into making the code more efficient and error-less.
How will this technology help you in career growth?
With new and emerging technologies, and new frameworks being used by the
software, this brings into play a great variety of code effectiveness. These
emerging technologies are a sure thing that is to be added into the Visual Studio
Code and its extensions. The developers, testers, data administrators, both old
and newbies, can equally use it, and that too very effectively. The people who are
into this industry might find it a bit tough to learn this new technology,
considering their use of more manual modes of code logic.
Conclusion
With advancements in technology day-by-day, Visual Studio Code is going to play
a pivotal role in the development of software. With its ever-evolving features and
soon-to-be-added new settings, which will enable users to work with it from
anywhere, it is certainly “THE THING” to keep one ahead of everyone in this ever-
increasing IT market.
BACK END USED
DJANGO
Introduction of Django
What is Django?
Django is a Python-based web framework which allows you to quickly create web
application without all of the installation or dependency problems that you normally
will find with other frameworks.
When you’re building a website, you always need a similar set of components: a
way to handle user authentication (signing up, signing in, signing out), a
management panel for your website, forms, a way to upload files, etc. Django gives
you ready-made components to use.
Why Django?
1. It’s very easy to switch database in Django framework.
2. It has built-in admin interface which makes easy to work with it.
3. Django is fully functional framework that requires nothing else.
4. It has thousands of additional packages available.
5. It is very scalable.
Popularity of Django
Django is used in many popular sites like as: Disqus, Instagram, Knight Foundation,
MacArthur Foundation, Mozilla, National Geographic etc. There are more than 5k
online sites based on the Django framework. ( Source )
Sites like Hot Frameworks assess the popularity of a framework by counting the
number of GitHub projects and StackOverflow questions for each platform, here
Django is in 6th position. Web frameworks often refer to themselves as
“opinionated” or “un-opinionated” based on opinions about the right way to handle
any particular task. Django is somewhat opinionated, hence delivers the in both
worlds( opinionated & un-opinionated ).
Features of Django
Versatility of Django
Django can build almost any type of website. It can also work with any client-side
framework and can deliver content in any format such as HTML, JSON, XML etc.
Some sites which can be built using Django are wikis, social networks, new sites etc.
Security
Since Django framework is made for making web development easy, it has been
engineered in such a way that it automatically do the right things to protect the
website. For example, In the Django framework instead of putting a password in
cookies, the hashed password is stored in it so that it can’t be fetched easily by
hackers.
Scalability
Django web nodes have no stored state, they scale horizontally – just fire up more of
them when you need them. Being able to do this is the essence of good scalability.
Instagram and Disqus are two Django based products that have millions of active
users, this is taken as an example of the scalability of Django.
Portability
All the codes of the Django framework are written in Python, which runs on many
platforms. Which leads to run Django too in many platforms such as Linux,
Windows and Mac OS.
Installation of Django
Install python3 if not installed in your system ( according to configuration
of your system and OS) from here . Try to download the latest version of
python it’s python 3.11.0 this time.
Note- Installation of Django in Linux and Mac is similar, here I am showing
it in windows for Linux and mac just open terminal in place of command
prompt and go through the following commands.
Install pip- Open command prompt and enter following command-
python -m pip install -U pip
1. Change directory to env_site by this command-
cd env_site
1. Go to Scripts directory inside env_site and activate virtual
environment-
cd
Scripts
activate
Install Django- Install django by giving following command-
pip install django
Return to the env_site directory-
cd ..
Start the server- Start the server by typing following command in cmd-
python manage.py runserver
To check whether server is running or not go to web browser and
enter http://127.0.0.1:8000/ as url.
Considerable efforts have made the software easy to operate even for the people
not related to the
field of computers but it is acknowledged that a layman may find it a bit
problematic at the first
instance. The user is provided help at each step for his convenience in working
with the software.
The users can add how many products he/she wants to their shopping cart.
Then the users are able to set the quantity of each added product inside the
cart.
Finally, while checkout the users can give their address and the mode of payment
and place the respective order. Then the admin can see the customer details with
his/her order details and the address where the order should be delivered.
Features:
User Authentication (register and login)
Session of each user is saved using cookies.
All Products with their view, key features and reviews by other users.
Users are able to search for any product.
Cart Functionality.
Proper Order Summary Before Placing Order.
Change Password Facility.
Contact Us.
Download Online Shopping System Django
Project
Please download the source code of python online shopping system from the
following link: Online Shopping System Python Django Project
Project File Structure
Steps for Online Shopping System Python Project:
Models.py :
class Customer(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
name = models.CharField(max_length=100)
email = models.CharField(max_length=100)
phone_number = models.CharField(max_length=10, null=True, blank=True)
def str (self):
return self.name
class Product(models.Model):
name = models.CharField(max_length=100)
price = models.FloatField()
image = models.ImageField(upload_to="images", default="")
def str (self):
return self.name
class Feature(models.Model):
product = models.ForeignKey(Product, on_delete=models.CASCADE)
feature = models.CharField(max_length=1000, null=True, blank=True)
def str (self):
return str(self.product) + " Feature: " + self.feature
class Review(models.Model):
customer = models.ForeignKey(Customer, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
content = models.TextField()
datetime = models.DateTimeField(default=now)
def str (self):
return str(self.customer) + " Review: " + self.content
class Order(models.Model):
customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, null=True)
date_ordered = models.DateTimeField(auto_now_add=True)
complete = models.BooleanField(default=False)
transaction_id = models.CharField(max_length=100)
def str (self):
return str(self.id)
@property
def get_cart_total(self):
orderitems = self.orderitem_set.all()
total = sum([item.get_total for item in orderitems])
return total
@property
def get_cart_items(self):
orderitems = self.orderitem_set.all()
total = sum([item.quantity for item in orderitems])
return total
class OrderItem(models.Model):
product = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True)
order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True)
quantity = models.IntegerField(default=0)
date_added = models.DateTimeField(auto_now_add=True)
def str (self):
return str(self.order)
@property
def get_total(self):
total = self.product.price * self.quantity
return total
class CheckoutDetail(models.Model):
customer = models.ForeignKey(Customer, on_delete=models.SET_NULL, null=True)
order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True)
phone_number = models.CharField(max_length=10, blank=True, null=True)
total_amount = models.CharField(max_length=10, blank=True,null=True)
address = models.CharField(max_length=300)
city = models.CharField(max_length=100)
state = models.CharField(max_length=100)
zipcode = models.CharField(max_length=100)
date_added = models.DateTimeField(auto_now_add=True)
def str (self):
return self.address
Code Explanation:
So, there are a total of 7 models created for this project.
Customer model:
It saves the basic data of the customers when they register themselves.
Product model:
It saves the data of the product. The admin can add a new product very
easily using this model.
Feature model:
The admin can select the product and write any features about it. And all the
features of that product will be visible to the users when they view a specific
product.
Review model:
All the customers can write a review about a product which the customers
can read before buying it.
Order model:
It stores the order details about the customer, mainly the order id.
OrderItems model:
It stores the order id of the customer from the order model and the products with
their quantity.
Create superuser:
After creating the models, we need to go to the admin panel to access the created
models. Hence, we need a superuser who can access the models from the admin
panel. The superuser can make any changes inside the models.
Creating superuser :
For creating the superuser use the following command:
Urls.py file
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index"),
path("cart/", views.cart, name="cart"),
path("checkout/", views.checkout, name="checkout"),
path("update_item/", views.updateItem, name="update_item"),
path("product_view/<int:myid>/", views.product_view, name="product_view"),
path("search/", views.search, name="search"),
path("contact/", views.contact, name="contact"),
path("loggedin_contact/", views.loggedin_contact, name="loggedin_contact"),
path("register/", views.register, name="register"),
path("change_password/", views.change_password, name="change_password"),
path("login/", views.Login, name="login"),
path("logout/", views.Logout, name="logout"),
]
Code Explanation:
Above mentioned are the app urls. Hence, create a file for the urls inside the
app. The last three urls are for the user authentication that is register, login and
logout. The other urls consist of the entire project.
Views.py:
def index(request):
data = cartData(request)
items = data['items']
order = data['order']
cartItems = data['cartItems']
products = Product.objects.all()
return render(request, "index.html", {'products':products, 'cartItems':cartItems})
Views.py:
def search(request):
data = cartData(request)
items = data['items']
order = data['order']
cartItems = data['cartItems']
if request.method == "POST":
search = request.POST['search']
products = Product.objects.filter(name contains=search)
return render(request, "search.html", {'search':search, 'products':products, 'cartItems':cartItems})
else:
return render(request, "search.html")
Code Explanation:
The customers can directly search for the product that they want on the search
option given on the navigation bar. Whatever the customers write on the search
bar will be sent through a post request and then saved inside a variable.
search = request.POST['search']
products = Product.objects.filter(name contains=search)
Afterwards, from the Product model the product name is filtered to the search
value. The result is then displayed in the same cards as on the home page.
Views.py:
def product_view(request, myid):
product = Product.objects.filter(id=myid).first()
feature = Feature.objects.filter(product=product)
reviews = Review.objects.filter(product=product)
data = cartData(request)
items = data['items']
order = data['order']
cartItems = data['cartItems']
if request.method=="POST":
content = request.POST['content']
review = Review(customer=customer, content=content, product=product)
review.save()
return redirect(f"/product_view/{product.id}")
return render(request, "product_view.html", {'product':product, 'cartItems':cartItems, 'feature':feature,
'reviews':reviews})
Product View:
Code Explanation:
After clicking on the view button, the customers can view the specific product
with their key features and reviews. After reading the key features and the
reviews about the product, the customer can buy the product by clicking on the
add to cart button. The customer who has brought that specific product can write
their review about the product which the other customer is able to read.
Cart Page:
Code Explanation:
By clicking on the shopping cart icon on the navigation bar, customers can see all
the added items in the cart. The users can then increase or decrease the
quantity of the products according to their requirements.
Views.py:
def checkout(request):
data = cartData(request)
items = data['items']
order = data['order']
cartItems = data['cartItems']
total = order.get_cart_total
if request.method == "POST":
address = request.POST['address']
city = request.POST['city']
state = request.POST['state']
zipcode = request.POST['zipcode']
phone_number = request.POST['phone_number']
payment = request.POST['payment']
shipping_adress = CheckoutDetail.objects.create(address=address, city=city, phone_number=phone_number,
state=state, zipcode=zipcode, customer=customer, total_amount=total, order=order, payment=payment)
shipping_adress.save()
if total == order.get_cart_total:
order.complete = True
order.save()
alert = True
return render(request, "checkout.html", {'alert':alert})
return render(request, "checkout.html", {'items':items, 'order':order, 'cartItems':cartItems})
Code Explanation:
Then finally on the checkout page the customer can see their order summary
before placing the order which is very much important. At last, the customers
need to fill in the checkout details that includes the exact address, city, zip code
etc and also choose the mode of payment. Then the customers can place their
orders.
Views.py:
def change_password(request):
if not request.user.is_authenticated:
return redirect('/login')
data = cartData(request)
items = data['items']
order = data['order']
cartItems = data['cartItems']
if request.method == "POST":
current_password = request.POST['current_password']
new_password = request.POST['new_password']
try:
u = User.objects.get(id=request.user.id)
if u.check_password(current_password):
u.set_password(new_password)
u.save()
alert = True
return render(request, "change_password.html", {'alert':alert})
else:
currpasswrong = True
return render(request, "change_password.html", {'currpasswrong':currpasswrong})
except:
pass
return render(request, "change_password.html", {'cartItems':cartItems})
Code Explanation:
All the customers can change their password by going to the change password
option. To check the current password (check_password) method is used and
(set_password) method is used to set the new password as current password.
7. Contact Us (contact.html):
<div class="container py-2 mt-3">
<h2>Contact Us</h2>
<form method="post">{% csrf_token %}
<div class="form-group mt-2">
<label>Name</label>
<input type="text" class="form-control mt-2" id="name" name="name" placeholder="Enter Your Name">
</div>
<div class="form-group mt-2">
<label>Email</label>
<input type="email" class="form-control mt-2" id="email" name="email" placeholder="Enter Your Email">
</div>
<div class="form-group mt-2">
<label>Phone</label>
<input type="number" class="form-control mt-2" id="phone" name="phone" placeholder="Enter Your Phone
Number">
</div>
<div class="form-group">
<div class="form-group mt-2">
<label>How May We Help You ?</label>
<textarea class="form-control mt-2" id="desc" name="desc" rows="3"></textarea>
</div>
<button type="submit" style="background-color: #8c5d4f; color: white; width: 8rem;" class="btn mt-
4">Submit</button>
</form>
Views.py:
def contact(request):
if request.method=="POST":
name = request.POST['name']
email = request.POST['email']
phone = request.POST['phone']
desc = request.POST['desc']
contact = Contact(name=name, email=email, phone=phone, desc=desc)
contact.save()
alert = True
return render(request, 'contact.html', {'alert':alert})
return render(request, "contact.html")
Code Explanation:
The customers can ask their queries or can contact us by filling a small form.
There are two different forms one for the logged in users and others who haven’t
registered themselves but want to contact us. If the user is a logged in user then
the user just have to write the message directly else the user needs to first give
his name, email and phone before contacting.
Views.py:
def tracker(request):
if not request.user.is_authenticated:
return redirect('/login')
data = cartData(request)
items = data['items']
order = data['order']
cartItems = data['cartItems']
if request.method == "POST":
order_id = request.POST['order_id']
order = Order.objects.filter(id=order_id).first()
order_items = OrderItem.objects.filter(order=order)
update_order = UpdateOrder.objects.filter(order_id=order_id)
print(update_order)
return render(request, "tracker.html", {'order_items':order_items, 'update_order':update_order})
return render(request, "tracker.html", {'cartItems':cartItems})
Code Explanation:
After placing the required order you will get an order id. That id can be further
used for tracking the order. In the track order menu you have to give your order
id for viewing the status of the order.
Summary:
We have successfully developed an Online Shopping System in Python Django
Framework. With this project, I think you will be understanding and loving Django
a lot more. You can download the entire source code which is mentioned at the
start of the project.
References and Bibliography
• Google
• http://www.javaworld.com/javaworld/jw-01-1998/jw-01-Credentialreview.html
• Django and rest webframework
• Head First Java 2nd Edition
• https://www.w3schools.com/python/
• Java and Software Design Concepts by Apress
• https://www.tutorialspoint.com/java/
• http://www.javatpoint.com/java-tutorial
• https://docs.oracle.com/javase/tutorial
• https://code.visualstudio.com/
• http://www.tutorialspoint.com/mysql/