0% found this document useful (0 votes)
18 views81 pages

Online Mobile Shopping Project Report

The document outlines the development of an Online Mobile Shopping website that enhances user experience by facilitating mobile phone purchases through a secure platform. It employs HTML for the front end, Python with the Django framework for the back end, and MySQL for data management, ensuring a robust, scalable, and secure system. The project includes various modules for user and administrator functionalities, emphasizing security, performance, and customer satisfaction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views81 pages

Online Mobile Shopping Project Report

The document outlines the development of an Online Mobile Shopping website that enhances user experience by facilitating mobile phone purchases through a secure platform. It employs HTML for the front end, Python with the Django framework for the back end, and MySQL for data management, ensuring a robust, scalable, and secure system. The project includes various modules for user and administrator functionalities, emphasizing security, performance, and customer satisfaction.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 81

TABLE OF CONTENTS

S. NO CONTENT PAGE

1. Abstract 1

2. System Configurations 3

3. Introduction to Python 7

4. Applications of Python 9

5. Introduction to MySQL 11

6. Key Features of MySQL 13

7. Project Introduction 17

8. Scope of the Project 21

9. Objective of the Project 23

10. Modules 25

11. Source Code 33

12. Output 63

13. MySQL Tables 65

14. Conclusion 67

15. Bibliography 69
ABSTRACT
The Online Mobile Shopping website project is designed to facilitate the
purchase of mobile phones from various brands and models, enhancing the
overall user experience. This platform includes a range of features to streamline
the shopping process, such as comprehensive product information, a secure
shopping cart, diverse payment options, and order tracking. Administrators
benefit from functionalities that enable efficient management of the product
catalogue, customer interactions, and order processing.

To achieve a robust and user-friendly interface, the project utilizes HTML for
the front-end and Python with the Django framework for the back end. MySQL
is employed to efficiently store and manage data. The system configuration,
comprising a web server and a database server, ensures smooth and secure
operations. The web server handles HTTP requests and hosts the website, while
the database server manages data related to products, customers, and orders.

Designed for responsiveness, security, and scalability, the website is poised to


adapt to the evolving demands of online shopping. This commitment to quality
service and flexibility underscores the Online Mobile Shopping website as a
reliable and enjoyable platform for purchasing mobile phones online.

To further enhance user satisfaction, the website employs advanced security


measures to safeguard sensitive customer information and transactions. This
includes SSL encryption for data transmission, regular security audits, and the
implementation of robust authentication protocols. Additionally, the website is
optimized for mobile devices, ensuring that customers can enjoy a seamless
shopping experience across various platforms. Continuous performance
monitoring and user feedback integration help maintain the website's efficiency
and responsiveness, making the Online Mobile Shopping website a trusted
destination for purchasing mobile phones.

1
2
SYSTEM CONFIGURATIONS
The system configuration for the Online Mobile Shopping website consists of the
following components:

Hardware Requirements

Web Server

A web server that hosts the website and handles the HTTP requests from the
clients. The web server is configured to run Python with Django framework,
which implements the web application logic and interacts with the database.
The web server also serves the static files, such as HTML, CSS, and JavaScript,
that compose the front-end interface of the website.

Database Server

A database server that stores and manages the data related to the products,
customers, orders, and other entities. The database server uses MySQL, a
relational database management system that supports transactions, indexing, and
querying. The database server communicates with the web server through a
secure connection and provides the data needed for the website's functionality.

The system configuration is designed to ensure that the website operates


smoothly and securely, while providing a high-quality service to the customers
and administrators. The system configuration also supports the scalability and
maintainability of the website, allowing for easy updates and enhancements as
the website grows and evolves.

3
4
Software Requirements

Windows as Operating System

The website will be hosted on a server running Windows as the operating system,
ensuring compatibility and stability for the web application's operations.

MySQL as Database

MySQL will serve as the database management system, providing a robust and
reliable platform for storing and querying the website's data.

HTML as Scripting Language

HTML will be utilized as the scripting language to structure the front-end of the
website, creating an intuitive and engaging user interface.

Python as Programming Language

Python will be the programming language of choice for the back-end


development, working in tandem with the Django framework to handle server-
side logic.

PyCharm as IDE

PyCharm will be the integrated development environment used for writing and
testing the website's code, offering a comprehensive suite of tools for
developers.

Other Security Measures

Additional security measures will be implemented, including but not limited to


secure communication protocols and data encryption, to protect the website and
its users from potential threats.

This configuration ensures that the website is not only user-friendly and feature-
rich but also secure and scalable, ready to meet the demands of online shoppers
and administrators alike.

5
6
INTRODUCTION TO PYTHON
Python is a high-level, interpreted programming language known for its
simplicity and readability. It was created by Guido van Rossum and first
released in 1991. Python's design philosophy emphasizes code readability with
its notable use of significant whitespace. Its language constructs and object-
oriented approach aim to help programmers write clear, logical code for small
and large- scale projects. Python is dynamically typed and garbage collected. It
supports multiple programming paradigms, including procedural, object-
oriented, and functional programming. Python is often described as a "batteries
included" language due to its comprehensive standard library.

One of the key features of Python is its interpretability, which means that scripts
written in Python are executed line by line at runtime. This makes debugging
easier and allows for immediate feedback during development. Python's syntax
is designed to be intuitive and its code more approachable and maintainable.

Python is widely used for web and software development, scientific computing,
artificial intelligence, data analysis, and automation. Its versatility, combined
with a vast ecosystem of libraries and frameworks, such as Django for web
development and NumPy for scientific computing, makes it a popular choice
among developers and researchers.

In summary, Python's ease of use, powerful libraries, and strong community


support have contributed to its widespread adoption and reputation as one of the
most popular programming languages in the world. Whether you're developing
a simple script or a complex machine learning algorithm, Python offers a rich
set of features and an intuitive approach to programming.

7
8
APPLICATIONS OF PYTHON
Python is a highly versatile and powerful programming language that is widely
used across various industries and applications due to its simplicity, readability,
and extensive library support. It is particularly renowned for its role in web
development, where frameworks such as Django and Flask allow developers to
build robust, scalable, and secure web applications efficiently.

One of the key applications of Python is in data science and machine learning.
Python's rich ecosystem of libraries, including NumPy, pandas, scikit-learn, and
TensorFlow, enables data scientists and analysts to perform complex data
manipulation, statistical analysis, and predictive modelling with ease.

In the realm of education, Python's straightforward syntax and readability make


it an excellent choice for teaching programming concepts to beginners. Many
educational institutions and online platforms use Python as the introductory
language for computer science courses, helping students grasp fundamental
programming principles and develop problem-solving skills.

Python's application extends to the field of artificial intelligence (AI) and


robotics as well. Its integration with AI libraries and frameworks allows
developers to create intelligent systems that can perform tasks such as natural
language processing, image recognition, and autonomous control. Python's role
in robotics includes programming robotic movements, sensor integration, and
communication between various robotic components.

In summary, Python's versatility, ease of use, and extensive library support


make it a preferred choice for a wide range of applications, from web
development and data science to automation, software development, education,
and AI. Its continued evolution and widespread adoption ensure that Python will
remain a cornerstone of modern programming for years to come.

9
10
INTRODUCTION TO MYSQL
MySQL is an open-source relational database management system (RDBMS)
that is widely used in web applications to store and manage data. It is known for
its reliability, performance, and ease of use. MySQL was originally developed
by MySQL AB, a Swedish company. The project's source code was released
under the GNU General Public License, and it quickly became popular in the
open- source community.

MySQL uses a client-server model and a structured query language (SQL) for
database access. It supports various data types, including numeric, date and
time, string, and spatial types. MySQL is also known for its scalability, allowing
it to handle large amounts of data and high numbers of concurrent users with
ease.

Security in MySQL includes a privilege and password system that is very


flexible and secure and that allows host-based verification. MySQL also offers
SSL support for encrypted connections and the ability to force all user
connections to go through SSL.

The development and maintenance of MySQL are now overseen by Oracle


Corporation, which acquired Sun Microsystems, the company that previously
owned MySQL AB, in 2010. Despite this, MySQL remains open source and is
available as free software under the terms of the GNU General Public License,
as well as under a variety of proprietary agreements.

MySQL has stood the test of time and continues to be a cornerstone of modern
database management, powering a significant portion of the internet and serving
as the backbone for countless applications. Its continued development and
widespread use are a testament to its robustness, versatility, and performance.

11
12
KEY FEATURES OF MYSQL
MySQL is a powerful relational database management system (RDBMS) suited
for modern web applications and enterprise solutions. Here are some key features:

High Performance

MySQL's architecture delivers excellent performance and scalability, efficiently


handling large datasets and high traffic loads for both small and large
applications.

Scalability

MySQL scales both vertically and horizontally, supporting large databases and
managing increased transactions without compromising performance, making it
ideal for growing businesses.

Robust Security

MySQL offers comprehensive security features, including fine-grained access


control, host-based verification, and SSL support, ensuring encrypted and
secure data transmission.

Flexibility

MySQL supports a wide range of data types, including numeric, date and time,
string, and spatial types, allowing developers to design databases for specific
needs.

Open Source and Community Support

MySQL is open source under the GNU General Public License, allowing free use,
modification, and distribution.

13
14
Ease of Use

MySQL is known for its user-friendly interface. The relational model and SQL
make it accessible to both novice and experienced developers. Tools like
MySQL Workbench simplify complex database tasks.

Reliability and High Availability

MySQL ensures data reliability and high availability with features like
replication, clustering, and backup solutions, creating redundant systems that
recover quickly in case of failure, ensuring minimal downtime.

In conclusion, MySQL's performance, scalability, security, and flexibility make


it a cornerstone in database management systems. Its open-source nature and
active community support ensure its relevance and power for developers
worldwide, providing a solid foundation for small web applications and large
enterprise solutions.

15
16
PROJECT INTRODUCTION
The Online Mobile Shopping website is an innovative project that aims to
revolutionize the way customers purchase mobile phones. By leveraging the
power of HTML for the front end, Python with the Django framework for the
back end, and MySQL for the database, this website offers a robust, secure, and
user-friendly platform for online shopping.

Front End: HTML

HTML, the cornerstone of web page design, is utilized to create a visually


appealing and intuitive interface for users. It ensures that customers can easily
navigate through the website, view products, and interact with the various
features offered.

Back End: Python with Django Framework

Python, known for its simplicity and efficiency, works in conjunction with the
Django framework to provide a powerful back-end solution. This combination
allows for the seamless processing of user requests, database management, and
the overall functionality of the website.

Database: MySQL

MySQL, a widely used database system, is employed to handle the vast amount
of data generated by the website. It ensures that all user data, product
information, and transaction details are stored securely and can be retrieved
efficiently.

User Experience

The website is designed with the customer in mind, offering features such as
advanced search filters, product comparisons, secure checkout processes, and
real-time order tracking. Users can also benefit from personalized
recommendations and a responsive design that adapts to various devices.

17
18
Administrator Functionality

For administrators, the Online Mobile Shopping website offers a dashboard for
managing inventory, processing orders, and tracking stock levels. It includes
real- time analytics and reporting tools for informed decision-making. The user-
friendly interface and customizable settings optimize workflow, enhancing the
platform's efficiency.

User Functionality

The Online Mobile Shopping website provides a variety of user functionalities


to improve the shopping experience. New users can create an account through
the Registration Module, while returning users can securely log in via the Login
Module. The Place Order Module allows users to select and purchase mobile
phones easily. The Shopping Cart Module helps them review selected items and
proceed to payment. The Manage Profile Module lets users update personal
information and manage their order history. These features, along with the
robust technology stack, ensure a reliable and enjoyable online shopping
journey.

Security and Scalability

Security is a top priority, with measures in place to protect user data and
transactions. The website's architecture is scalable, ensuring it can handle
increased traffic and data as the business grows.

In conclusion, The Online Mobile Shopping website project stands out as a


prime example of how modern technologies can be harnessed to create a
convenient, secure, and enjoyable online shopping experience for both
customers and administrators. It is a testament to the potential of combining
HTML, Python with Django, and MySQL to build a successful e-commerce
platform.

19
20
SCOPE OF THE PROJECT
The scope of the Online Mobile Shopping website project are to create a
comprehensive e-commerce platform that simplifies the process of purchasing
mobile phones online. The project aims to provide a user-friendly interface that
allows customers to easily browse and compare a wide range of mobile phones
from various brands and models. The website will feature advanced
functionalities such as a registration module for new users, a login module for
returning customers, a shopping cart module to review and manage purchases, a
place order module for secure transactions, and a manage profile module for
users to maintain their personal information and order history.

From an administrative perspective, the website will offer a dashboard for


managing inventory, processing orders, and analyzing customer behavior to
improve the shopping experience. The project will leverage HTML for the
front- end design, Python with the Django framework for back-end operations,
and MySQL for database management, ensuring a robust, secure, and scalable
system.

21
22
OBJECTIVE OF THE PROJECT
The objective is to deliver a platform that not only meets the current demands of
online shopping but also adapts to future trends and technologies. The project is
committed to providing a seamless shopping experience, with a focus on
security, performance, and customer satisfaction. By achieving these goals, the
Online Mobile Shopping website will establish itself as a leading destination for
mobile phone consumers.

The project will harness the capabilities of HTML to craft a responsive and
engaging front-end user interface. Python, with its powerful Django framework,
will serve as the backbone of the back-end operations, ensuring efficient
handling of server-side logic and interactions. MySQL will be utilized as the
database management system, providing a secure and organized structure for
storing and managing the website's data.

The technology stack has been carefully selected to ensure the website is not
only user-friendly but also robust and scalable. HTML will enable the creation
of a visually appealing layout that is easy to navigate. Python and Django will
offer a secure and flexible environment for developing the website's
functionality, while MySQL will ensure data integrity and fast query
processing.

The project's objective extends beyond the development of the website to


include the implementation of advanced features and security measures. These
will guarantee a seamless and secure shopping experience for customers and
provide administrators with powerful tools to manage the website's operations
effectively.

In summary, the Online Mobile Shopping website project aims to deliver a


platform that excels in performance, security, and user experience by leveraging
the strengths of HTML, Python with Django, and MySQL. The project is
committed to setting a new standard for online mobile phone retail, with a focus
23
on innovation, customer satisfaction, and operational excellence.

24
25
MODULES
The Online Mobile Shopping website project is designed with a robust set of
administrative functionalities that ensure smooth operation and management of
the e-commerce platform. These functionalities are accessible through a secure
admin panel, which is the control centre for the website's operations.

Login Module

The admin panel features a secure Login Module that requires administrators to
authenticate themselves before gaining access. This module is built with
security best practices to prevent unauthorized access and protect sensitive data.

Manage Category Module

Within the admin panel, the Manage Category functionality allows


administrators to create, update, and delete product categories. This is crucial
for organizing the inventory and helps customers find products more efficiently.

 Add Category: Administrators can add new categories to the website,


defining the name, description, and relevant attributes that characterize
the products within that category.
 Update Category: The platform allows for easy updating of category
details, ensuring that the information remains accurate and up to date.
 Delete Category: Administrators have the ability to remove categories
that are no longer needed, which helps maintain a clean and organized
category structure.

Manage Items Module

The Manage Items functionality is a key component of the admin panel, enabling
administrators to oversee the individual products listed on the website.

26
27
 Add Item: Administrators can add new items to the inventory, inputting
detailed information such as product name, description, specifications,
pricing, and images.
 Update Item: The platform facilitates the updating of item details,
allowing for changes in price, availability, and other product attributes as
needed.
 Delete Item: Administrators can remove items from the website, which is
particularly useful for products that are discontinued or out of stock.

These administrative capabilities are supported by the website's underlying


technologies. The front end, powered by HTML, provides a clean and intuitive
interface for these administrative tasks. Python with the Django framework
ensures that the back-end operations are secure and efficient, while MySQL
manages the data integrity and provides quick access to the necessary
information.

The admin functionalities are designed to be user-friendly, allowing


administrators to manage the website's content and operations with ease. The
goal is to provide a seamless experience for both the administrators and the
customers, ensuring the website remains a competitive and attractive platform
for online mobile shopping. The project's commitment to using advanced
technologies like HTML, Python with Django, and MySQL guarantees that the
admin panel is not only powerful but also adaptable to future enhancements and
growth.

Registration Module

The Registration Module allows new users to create an account on the website.
This process is streamlined to ensure a quick and hassle-free registration,
requiring only essential information from the user. Once registered, users can
enjoy a personalized shopping experience, save their preferences, and expedite
future transactions.
28
29
Login Module

The Login Module provides returning users with secure access to their accounts.
By entering their credentials, users can quickly resume their shopping activities,
access their order history, and manage their account details. The module is
designed with security measures to protect user information and prevent
unauthorized access.

Place Order Module

The Place Order Module is a critical feature that enables users to securely
purchase mobile phones. It guides users through the selection of products,
addition to the cart, and the checkout process. The module ensures that all
transactions are conducted securely, with various payment options available to
suit different preferences.

Shopping Cart Module

The Shopping Cart Module offers users a convenient place to review and
manage their selected items before proceeding to checkout. Users can adjust
quantities, remove items, or continue shopping before finalizing their purchase.
The module provides a clear summary of the products and the total cost,
including any applicable taxes and shipping fees.

Manage Profile Module

The Manage Profile Module gives users control over their personal information
and account settings. Users can update their contact details, change their
password, and manage their shipping addresses. The module also allows users
to review their order history and track the status of current orders.

These user-centric features are supported by the website's robust technology


stack, ensuring a reliable and enjoyable online shopping journey. The front end,
powered by HTML, provides a clean and intuitive interface for these user tasks.

30
31
Python with the Django framework ensures that the back-end operations are
secure and efficient, while MySQL manages the data integrity and provides
quick access to the necessary information.

The user functionalities are designed to be user-friendly, allowing customers to


navigate the website's content and operations with ease. The goal is to provide a
seamless experience for both the users and the administrators, ensuring the
website remains a competitive and attractive platform for online mobile
shopping. The project's commitment to using advanced technologies like
HTML, Python with Django, and MySQL guarantees that the user interface is
not only powerful but also adaptable to future enhancements and growth. The
Online Mobile Shopping website project aims to deliver a platform that excels
in performance, security, and user experience by leveraging the strengths of
these technologies.

32
33
SOURCE CODE

Code Structure

OnlineShopping

Shop

34
35
HTML Templates

manage.py

#!/usr/bin/env python
"""Django's command-line utility for administrative
tasks.""" import os
import sys

def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE',
'OnlineShopping.settings') try:
from django.core.management import
execute_from_command_line except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you
" "forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)

if name == ' main ':


main()

36
37
asgi.py

"""
ASGI config for OnlineShopping project.

It exposes the ASGI callable as a module-level variable named


``application``.

For more information on this file, see


https://docs.djangoproject.com/en/3.1/howto/deployment/as
gi/ """

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'OnlineShopping.settings')

application = get_asgi_application()

settings.py

from pathlib import Path


import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.


BASE_DIR = Path( file ).resolve().parent.parent

# Quick-start development settings - unsuitable for production


# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production


secret! SECRET_KEY = 'ujsx7y@d*q^b)ta6v6=v!3)ut4e0-
zsg6xtlfp3qirfp5$#(3q'

# SECURITY WARNING: don't run with debug turned on in


production! DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',

38
'django.contrib.sessions',

39
40
'django.contrib.messages',
'django.contrib.staticfiles
', 'shop',
'django.contrib.humanize',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'OnlineShopping.urls'

TEMPLATES = [
{
'BACKEND':
'django.template.backends.django.DjangoTemplates',
'DIRS': ["shop/templates"],
'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',
],
},
},
]

WSGI_APPLICATION = 'OnlineShopping.wsgi.application'

# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}

41
42
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-
validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME':
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N =

True USE_L10N

= True USE_TZ

= True

# Static files (CSS, JavaScript, Images)


# https://docs.djangoproject.com/en/3.1/howto/static-

files/ STATIC_URL = '/static/'

MEDIA_ROOT = os.path.join(BASE_DIR,
'shop/media') MEDIA_URL = '/media/'

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

44
45
urls.py

from django.contrib import admin


from django.urls import path,
include from django.conf import
settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('shop.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

wsgi.py

"""
WSGI config for OnlineShopping project.

It exposes the WSGI callable as a module-level variable named


``application``.

For more information on this file, see


https://docs.djangoproject.com/en/3.1/howto/deployment/ws
gi/ """

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'OnlineShopping.settings')

application = get_wsgi_application()

admin.py

from django.contrib import


admin from . models import *

admin.site.register(Customer)
admin.site.register(Product)
admin.site.register(Feature)
admin.site.register(Review)
admin.site.register(Order)
admin.site.register(OrderItem)
admin.site.register(CheckoutDetail)
admin.site.register(UpdateOrder)
admin.site.register(Contact)

46
47
apps.py

from django.apps import AppConfig

class
ShopConfig(AppConfig):
name = 'shop'

inherit.py

import json
from . models import *

def cartData(request):
if request.user.is_authenticated:
customer =
request.user.customer
order, created = Order.objects.get_or_create(customer=customer,
complete=False)
items =
order.orderitem_set.all()
cartItems = order.get_cart_items
else:
items = []
order = {'get_cart_total':0, 'get_cart_items':0}
cartItems = order['get_cart_items']
return {'cartItems':cartItems, 'items':items, 'order':order}

models.py

from django.db import models


from django.contrib.auth.models import
User from django.utils.timezone import
now

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 str(self.user)

class Product(models.Model):
name =
48
models.CharField(max_length=100)
price = models.FloatField()
image = models.ImageField(upload_to="",

default="") def str (self):

49
50
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(default=now) complete =
models.BooleanField(default=False)

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(default=now)

51
def str (self):
return str(self.order)

52
53
@property
def get_total(self):
total = self.product.price *
self.quantity return total

class UpdateOrder(models.Model):
order_id = models.ForeignKey(Order,
on_delete=models.CASCADE) desc =
models.CharField(max_length=500)
date = models.DateField(default=now)

def str (self):


return str(self.order_id)

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)
payment = models.CharField(max_length=100,
blank=True) date_added =
models.DateTimeField(default=now)

def str (self):


return
self.address

class Contact(models.Model):
name =
models.CharField(max_length=100)
email =
models.CharField(max_length=50)
phone =
models.CharField(max_length=10) desc
= models.CharField(max_length=1000)

def str (self):


return self.name

urls.py
54
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"),

55
56
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("tracker/", views.tracker,
name="tracker"), 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"),
]

views.py

from django.http.response import


HttpResponse from django.shortcuts import
render, redirect from .models import *
from django.http import
JsonResponse import json
from django.contrib.auth.models import User
from django.contrib.auth import authenticate, login,
logout from . inherit import cartData

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})

def cart(request):
data =
cartData(request) items
= data['items'] order =
data['order']
cartItems =
data['cartItems'] try:
cart =
json.loads(request.COOKIES['cart']) except:
cart = {}

57
print('Cart:', cart)

for i in cart:

58
59
try
: cartItems += cart[i]["quantity"]

product = Product.objects.get(id=i)
total = (product.price * cart[i]["quantity"])

order["get_cart_total"] += total
order["get_cart_items"] += cart[i]["quantity"]

item = {
'product':{
'id':product.id,
'name':product.name,
'price':product.price,
'image':product.image,
},
'quantity':cart[i]["quantity"],
'get_total':total
}
items.append(item)
except:
pass
return render(request, "cart.html", {'items':items, 'order':order,
'cartItems':cartItems})

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=request.user.customer, total_amount=total, order=order,
payment=payment)
shipping_adress.save()
if total ==
order.get_cart_total:
60
order.complete = True
order.save()
id =
order.id
alert = True

61
62
return render(request, "checkout.html", {'alert':alert,
'id':id}) return render(request, "checkout.html", {'items':items,
'order':order,
'cartItems':cartItems})

def updateItem(request):
data =
json.loads(request.body)
productID = data['productID']
action = data['action']

print('Action:', action)
print('productID:', productID)

customer = request.user.customer
product = Product.objects.get(id=productID)
order, created = Order.objects.get_or_create(customer=customer,
complete=False)
orderItem, created = OrderItem.objects.get_or_create(order=order,
product=product)
update_order, created = UpdateOrder.objects.get_or_create(order_id=order,
desc="Your Order is Successfully Placed.")

if action == 'add':
orderItem.quantity = (orderItem.quantity
+ 1) elif action == 'remove':
orderItem.quantity = (orderItem.quantity - 1)

orderItem.save()
update_order.save()

if orderItem.quantity <= 0:
orderItem.delete()
return JsonResponse('Item was added', safe=False)

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)
63
review.save()
return redirect(f"/product_view/{product.id}")

64
65
return render(request, "product_view.html", {'product':product,
'cartItems':cartItems, 'feature':feature, 'reviews':reviews})

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")

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
66
return render(request, "change_password.html", {'cartItems':cartItems})

def contact(request):
if request.method=="POST":
name =
request.POST['name']
email =
request.POST['email']
phone =
request.POST['phone'] desc
= request.POST['desc']

67
68
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")

def
loggedin_contact(reques
t): data =
cartData(request) items
= data['items'] order =
data['order']
cartItems =
data['cartItems'] if
request.method=="POST":
name = request.user
email = request.user.email
phone =
request.user.customer.phone_number desc =
request.POST['desc']
contact = Contact(name=name, email=email, phone=phone, desc=desc)
contact.save()
alert = True
return render(request, 'loggedin_contact.html',
{'alert':alert}) return render(request, "loggedin_contact.html",
{'cartItems':cartItems})

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})

def register(request):
69
if request.user.is_authenticated:
return redirect("/")
else:
if request.method=="POST":
username = request.POST['username']
full_name=request.POST['full_name']
password1 = request.POST['password1']
password2 = request.POST['password2']

70
71
phone_number =
request.POST['phone_number'] email =
request.POST['email']

if password1 != password2:
alert = True
return render(request, "register.html", {'alert':alert})

user = User.objects.create_user(username=username,
password=password1, email=email)
customers = Customer.objects.create(user=user, name=full_name,
phone_number=phone_number, email=email)
user.save()
customers.save()
return render(request, "login.html")
return render(request, "register.html")

def Login(request):
if request.user.is_authenticated:
return redirect("/")
else:
if request.method == "POST":
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)

if user is not None:


login(request,
user) return
redirect("/")
else:
alert = True
return render(request, "login.html",
{"alert":alert}) return render(request, "login.html")

def
Logout(request):
logout(request)
alert = True
return render(request, "index.html", {'alert':alert})

72
73
OUTPUT
Home

User Registration

User Login

74
75
MYSQL TABLES

76
77
CONCLUSION
The Online Mobile Shopping website project represents a significant
advancement in the realm of e-commerce, particularly in the mobile phone retail
sector. By integrating HTML, Python with the Django framework, and MySQL,
the project has successfully developed a platform that is not only aesthetically
pleasing and user-friendly but also robust, secure, and highly functional.

The project aimed to deliver a comprehensive online shopping experience for


both customers and administrators. It provides seamless registration, secure
login, intuitive shopping cart functionality, straightforward order placement, and
personal profile management for customers. For administrators, it offers
powerful tools for managing product categories, inventory, and orders, ensuring
an up-to- date and appealing product offering.

For administrators, the website delivers a powerful dashboard equipped with


tools for managing product categories, inventory, and orders. This level of
control and oversight ensures that the website can maintain an up-to-date and
attractive product offering, respond to market trends, and provide exceptional
customer service.

The project's use of advanced technologies has laid a solid foundation for
scalability and future growth. The choice of HTML for the front end allows for
creative and responsive design, while Python and Django offer a secure and
efficient back-end structure. MySQL's reliable database management
capabilities ensure that the website can handle large volumes of data and
transactions without compromising performance.

In conclusion, the Online Mobile Shopping website project has achieved its
objectives and set a new benchmark for online mobile phone retail platforms. It
stands as a testament to the power of combining cutting-edge technology with a
deep understanding of user needs and market demands.

78
79
BIBLIOGRAPHY
1. www.google.com
2. https://www.python.org/
3. https://pip.pypa.io/en/stable/cli/pip_install/
4. https://www.djangoproject.com/
5. https://www.mysql.com/
6. https://www.geeksforgeeks.org/
7. https://www.w3schools.com/

80

You might also like