Nischitha
Nischitha
JNANASANGAMA, BELGAVI-590018
Submitted by
MEGHANA SREENIVASA RAO (1BI19IS031)
NISCHITHA NAGARURU (1BI19IS037)
2021-2022
DEPARTMENT OF INFORMATION SCIENCE AND ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY
CERTIFICATE
This is to certify that the implementation of DBMS MINI PROJECT (18CSL58) entitled
“ONLINE GROCERY SHOP MANAGEMENT SYSTEM” has been successfully completed
by NISCHITHA NAGARURU (1BI19IS037) of V semester B.E. for the partial fulfilment of
the requirements for the Bachelor's degree in Information Science & Engineering of the
Visvesvaraya Technological University during the academic year 2021-2022.
1.
2.
DECLARATION
i
ACKNOWLEDGEMENT
The satisfaction and euphoria that accompany the successful completion of any
task would be incomplete without the mention of the people who made it
possible. So, with gratitude, I acknowledge all those whose guidance and
encouragement crowned my effort with success.
It’s immense pleasure in thanking principal Dr. Ashwath M.U, BIT, Bangalore,
for providing an opportunity to present this project as a part of my curriculum in
the partial fulfilment of the degree.
I would like to thank all teaching and non-teaching staff of ISE Department
for providing their valuable guidance and for being there at all the stages of my
world.
ii
ABSTRACT
This project aims at developing an online grocery shop management system for customers
with the goal of making buying groceries in an easy and simple manner without having
to step out of house. The project contains the customer side and the admin side. The
customer can order products online and see his orders. Thus, it’s a digital way of
management of the product order and also payment system. An online Grocery Store
permits a customer to submit online orders for items and/or services from a store that
serves both walk-in customers and online customers. The online Store system presents an
online display of all the items they want to sell. This web-based application helps
customers to choose their daily needs and add products to their shopping cart. Customers
provides their complete detail of address and contact and they get their chosen products
in their home.
This Web application saves lots of time of customers. The appeal of e-grocery services is
also influenced by many consumers finding grocery shopping a stressful activity. In
addition to time-starved and stressed consumers, individuals with disabilities related to
age and health are another prominent market for e-grocery service.
iii
TABLE OF CONTENTS
DECLARATION I
ACKNOWLEDGMENT II
ABSTRACT III
TABLE OF CONTENTS IV
LIST OF FIGURES VI
1 INTRODUCTION 1-4
1.4 Objectives 4
3 DESIGN 6-17
3.1 ER Analysis 6
iv
3.4 Tables and Functional Dependencies 14
3.5 Normalization 16
4 IMPLEMENTATION 18-72
4.4.2 Triggers 71
6 SNAPSHOTS 76-82
v
LIST OF FIGURES
vi
LIST OF TABLES
vii
GROCERY MANAGEMENT SYSTEM 1BI19IS037
CHAPTER 1
INTRODUCTION
Database is a collection of data and Management System is a set of programs to store and
retrieve those data. Based on this one can define DBMS as a collection of inter-related data
and set of programs to store & access those data in an easy and effective manner.
Storage: According to the principles of database systems, the data is stored in such a way
that it acquires lot less space as the redundant data (duplicate data) has been removed before
storage. Let’s take a layman example to understand this. In a banking system, suppose a
customer is having two accounts, one is saving account and another is salary account. Let’s
say bank stores saving account data at one place and salary account data at another place, in
that case if the customer information such as customer name, address etc. are stored at both
places then this is just a wastage of storage (redundancy/ duplication of data), to organize
the data in a better way the information should be stored at one place and both the accounts
should be linked to that information somehow. The same thing we achieve in DBMS.
Fast Retrieval of data: Along with storing the data in an optimized and systematic manner,
it is also important to retrieve the data quickly when needed. Database systems ensure that
the data is retrieved as quickly as possible.
In grocery shop management system, we can overcome all these drawbacks by creating a
contactless shopping experience, help people order groceries despite their busy schedule
from any part of the city or any place with the help of electronic gadgets like laptops and
phones.
There is also an admin side to the grocery shop included, where the admin will be able to
login with the specified credentials and change contents and manage the web page which
handle the grocery management system.
1.4 Objectives
The aim of this project is to create a simple, efficient grocery management system which
makesonline grocery shopping easy for the consumers and includes all the functionality that is
required by them. Online grocery shopping is a dream come true for today’s generation.
Specially, for all those women/men who always wanted to do grocery shopping on a budget.
The landscape of grocery fulfilment has changed greatly, and there are certain advantages and
disadvantages to online grocery shopping.
Shopping online alleviates the need to walk up and down store aisles. And you can log in any
time even at 2 am and still have the advantage of a fully stocked store. Plus, going the
delivery route saves you a trip to the store, which not only saves time, but gas money as well.
In fact, studies show grocery delivery services slash carbon dioxide emissions in half
compared to individual household trips. Search engines on websites make it much easier to
find items quickly; typing in the name or brand of a product will show you all relevant
products making itmuch easier to find exactly what you need.
The main purpose of online grocery is to create and develop new models, and to optimize the
relationships between a grocery company and its customers. Changing from shopping at the
supermarket to online grocery shopping can improve an online grocery retailer’s productivity
by shortening supply chains, reducing overhead costs, and enabling “just in time” service.
CHAPTER 2
CHAPTER 3
DESIGN
In the below section, a brief overview of how the project is designed is given, including the Entity
Relation diagram and Schema diagram which describes the various attributes used in the design
ENTITIES
1. auth_group
2. auth_group_permissions
3. auth_permission
4. auth_user
5. auth_user_permissions
6. admin_log
7. content_type
8. migrations
9. session
10. main_cart_items
11. main_type
Table 3.1
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Primary key
Name VARCHAR(150)
Table 3.2
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Primary key
group_id INTEGER Primary key
permission_id INTEGER Primary key
Table 3.3
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Foreign key
content_type_id INTEGER Non key attribute
Codename VARCHAR(100) Primary key
Name VARCHAR(255) Non key attribute
4. auth_user: Attributes of this entity are id, password, last_login, is_superuser, username, first_name, email,
is_staff, is_active, date_joined, last_name
Table 3.4
Table 3.5
5. admin_log: Attributes of this entity are id, action_time, object_repr, change_message, content_type_id,
user_id, action_flag
Table 3.6
Table 3.7
Table 3.8
9. main_cart_items: Attributes of this entity are id, ordered, quantity, item_id, user_id, ordered_date, status,
delivery_date
Table 3.10
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Foreign key
Ordered BOOL Non key attribute
Quantity INTEGER Non key attribute
item_id INTEGER Non key attribute
user_id INTEGER Foreign key
ordered_date DATE Non key attribute
Status VARCHAR(20) Non key attribute
delivery_date DATE Non key attribute
10. main_items: Attributes of this entity are id, title, description, price, piece, pieces, instructions, image,
labels,label_color, slug, created_by_id
Table 3.11
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Foreign key
Title VARCHAR(150) Non key attribute
Description VARCHAR(250) Non key attribute
Price REAL Non key attribute
Pieces INTEGER Non key attribute
Instructions VARCHAR(250) Non key attribute
Images VARCHAR(100) Non key attribute
Labels VARCHAR(25) Non key attribute
label_color VARCHAR(10) Non key attribute
Slug VARCHAR(50) Non key attribute
created_by_id INTEGER Non key attribute
A relationship type represents the association between entity types. A set of relationships
of same type is known as relationship set.
The following are the relationships between the various entities used in the project.
• Has permissions: to check the permissions various groups have in the management
system
• Authenticates: for one group, usually the admin, to grant permission to another group
• Verifies: for one group, usually the admin, to verify the credentials and to give access to
something
• Accesses: usually, the admin has access to the main cart items, to add, delete, update
information on various items
• Gets added: the admin gets to add items to be displayed in the home page of the
management system
• Adds: here, the authenticated user, usually a supplier, add details and items to be
displayed and accessed on the home page
The cardinality or fundamental principle of one data aspect with respect to another is a critical
feature. The relationship of one to the other must be precise and exact between each other in
order to explain how each aspect links together. In simple words Cardinality is a way to define
the relationship between two entities.
The following are the notations of the ER diagram:
The ER diagram below shows the relationship between the many tables that exist in the
database for the functioning of Grocery Shop Management System.
In any data model it is important to distinguish between the description of the database and the
database itself. The description of a database is called the database schema, which is specified
during database design and is not expected to change frequently. A displayed schema is called
a schema diagram. A schema diagram displays only some aspects of a schema, such as the
names of record types and data items, and some types of constraints.
Functional Dependency (FD) is a constraint that determines the relation of one attribute to
another attribute in a Database Management System (DBMS). Functional Dependency helps
to maintain the quality of data in the database. It plays a vital role to find the difference between
good and bad database design.
10. main_item ( id, title, description, price, piece, pieces, instructions, image, labels, label_color,
slug, created_by_id)
FD = { id → title, labels, color, description }
created_by_id is a foreign key constraint
11. main_cartitems ( id, ordered, quantity, item_id, user_id, ordered_date, status, delivery_date)
FD= { id → item_id, quantity, ordered }
id is a foreign key constraint
3.5 Normalization
For a table to be in the First Normal Form, it should follow the following 4 rules:
1. It should only have single(atomic) valued attributes/columns.
2. Values stored in a column should be of the same domain
3. All the columns in a table should have unique names.
4. And the order in which data is stored, does not matter.
All the tables have achieved 1NF by converting multi-valued attribute Permissions into
separate entities like user_permissions or user group permissions.
All the tables which are part of this project are in 2NF as they have at most one
primarykey, so no partial dependency.
BCNF (Boyce Codd Normal Form) is the advanced version of 3NF. A table is in
BCNFif every functional dependency X->Y, X is the super key of the table. For
BCNF, the table should be in 3NF, and for every FD. LHS is super key.
Fourth normal form (4NF) is a level of database normalization where there are no non-
trivial multivalued dependencies other than a candidate key. It builds on the first three
normal forms (1NF, 2NF and 3NF) and the Boyce-Codd Normal Form (BCNF).
A relation is in 5NF if it is in 4NF and not contains any join dependency and
joiningshould be lossless.
All the tables we have used, do not contain any multivalued dependencies or
joindependencies. Thus, no case of generating additional invalid tuples arise.
CHAPTER 4
IMPLEMENTATION
This section focuses on the implementation of the online grocery shopping management system.
The steps and the technologies used are listed below.
• Every user will login using existing credentials, or sign up to create an account by
entering a valid phone number and email and set a password.
• The admin will be able to add items or delete items on the main catalog and also by able
tocheck the reviews on the admin page.
• Be able to view the list of all orders and reviews on the admin page.
• Customers will be able to add items to the cart, be able to checkout and view the invoice.
Hypertext Markup Language is the standard markup language for documents designed to
be displayed in a web browser. It can be assisted by technologies such as Cascading Style
Sheets and scripting languages such as JavaScript.
CSS
Cascading Style Sheets is a style sheet language used for describing the presentation of
a document written in a markup language like HTML. CSS is a cornerstone technology
of the World Wide Web, alongside HTML and JavaScript. Functional Modules.
Django
Django is a high-level Python Web framework that encourages rapid development and clean
pragmatic design. A Web framework is a set of components that provide a standard way to
develop websites fast and easily. Django’s primary goal is to ease the creation of complex
database-driven websites. Some well-known sites that use Django include PBS, Instagram,
Disqus, Washington Times, Bitbucket and Mozilla.
<hr class="sidebar-divider">
<li class="nav-item">
<a class="nav-link">
<li class="nav-item">
<a class="nav-link" href="{% url 'main:home' %}">
<i class="fa fa-home"></i>
<span>Home</span></a>
</li>
<li class="nav-item ml-3 mb-3">
<form class="logout-link" action="{% url 'accounts:logout' %}" method="post">
{% csrf_token %}
<button type="submit" class="mr-2">Logout</button>
</form>
</li>
<hr class="sidebar-divider d-none d-md-block">
</ul>
<div id="content-wrapper" class="d-flex flex-column">
<div id="content">
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
<h2 class="text-center">AdminPage</h3>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-xl-4 col-md-4 mb-4">
<div class="card border-left-success shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">Total
Earnings</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">₹ {{ income }}</div>
</div>
<div class="col-auto">
</div>
<div class="col-xl-4 col-md-4 mb-4">
<div class="card border-left-primary shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Total Delivered</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ completed_total }}</div>
</div>
<div class="col-auto">
<i class="fas fa-comments fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-4 col-md-4 mb-4">
<div class="card border-left-danger shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-danger text-uppercase mb-1">Pending Orders</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ pending_total }}</div>
</div>
<div class="col-auto">
<i class="fas fa-comments fa-2x text-gray-300"></i>
</div>
</div>
<div class="row">
<div class="col-xl-6 col-lg-6">
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Categories Bar Chart</h6>
</div>
<div class="card-body">
<div class="chart-pie pt-4 pb-2">
<canvas id="myChart"></canvas>
</div>
</div>
</div>
</div>
<div class="col-xl-6 col-lg-6">
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Categories Doughnut Chart</h6>
</div>
<div class="card-body">
<canvas id="myAreaChart"></canvas>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-
KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-
ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-
JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script>
let myChart = document.getElementById('myChart').getContext('2d');
let myAreaChart = document.getElementById('myAreaChart').getContext('2d');
let count1 = {{ count1 }};
let count2 = {{ count2 }};
let count3 = {{ count3 }};
let orderChart1 = new Chart(myChart, {
type:'bar',
data:{
labels:['Spicy Avocado', 'Tempura', 'Maki'],
datasets:[{
label:'Items',
data:[
count1,
count2,
count3,
],
backgroundColor:[
'#007BFF',
'#28A745',
'#FFC107',
],
}]
},
options:{
layout:{
padding:{
left:0,
right:0,
bottom:40,
top:0
}
},
});
let orderChart2 = new Chart(myAreaChart, {
type:'doughnut',
data:{
labels:['Spicy Avocado', 'Tempura', 'Maki'],
datasets:[{
label:'Items',
data:[
count1,
count2,
count3,
],
backgroundColor:[
'#007BFF',
'#28A745',
'#FFC107',
],
borderWidth:1,
borderColor:'#777',
hoverBorderWidth:1,
hoverBorderColor:'#000'
}]
},
options:{
layout:{
padding:{
left:0,
right:0,
bottom:40,
top:0
}
},
});
</script>
</body>
</html>
Admin_view
{% extends "main/layout2.html" %}
{% block content %}
<div class="cart">
<div class="container">
<div class="row">
<div class="col-sm-12">
<h3 class="text-center">Completed Orders</h3>
{% if cart_items %}
<div class="table-responsive">
<table class="table table-dark">
<thead>
<tr>
<td scope="col">Order No.</td>
<th scope="col">User</th>
<th scope="col">User Email</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Specification</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>
<th scope="col">Status</th>
<th scope="col">Delivery Date</th>
</tr>
</thead>
<tbody>
{% for cart in cart_items %}
<tr>
<td>{{ cart.id }}</td>
<td>{{ cart.user.username }}</td>
<td>{{ cart.user.email}}</td>
<td>{{ cart.item.title }} <span class="badge badge-{{ cart.item.label_colour }}">{{
cart.item.labels }}</span></td>
<td>{{ cart.item.description }}</td>
<td>{{ cart.item.instructions }}</td>
<td>{{ cart.item.price }}</td>
Cart.html
{% extends "main/layout.html" %}
{% block content %}
<div class="cart">
<div class="container">
<div class="row">
<div class="col-sm-9 mt-5">
<h3 class="text-center">Your Cart</h3>
{% if cart_items %}
<div class="table-responsive">
<table class="table table-light">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>
</tr>
</thead>
<tbody>
{% for cart in cart_items %}
<tr>
<td>{{ cart.item.title }} <span class="badge badge-{{ cart.item.label_colour }}">{{
cart.item.labels }}</span></td>
<td>{{ cart.item.description }}</td>
<td>{{ cart.item.instructions }}</td>
<td>{{ cart.item.price }}</td>
<td>{{ cart.item.pieces }} pieces</td>
<td><a class="btn btn-danger" href="{% url 'main:remove-from-cart' cart.id
%}">Delete</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
{% endblock content %}
Cart_itemsdelete.html
{% extends "main/layout.html" %}
{% block content %}
<div class="content-section container">
<form method="POST">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Delete Cart Item</legend>
<h2>Are you sure you want to delete the post "{{ object.item.title }}"</h2>
</fieldset>
<div class="form-group">
<button class="btn btn-danger" type="submit">Yes, Delete</button>
<a class="btn btn-success" href="{% url 'main:cart' %}">Cancel</a>
</div>
</form>
</div>
{% endblock content %}
Dishes.html
{% extends "main/layout.html" %}
{% block content %}
<div class="dishes">
<!--Main layout-->
<main class="mt-3 pt-4 main">
<div class="container dark-grey-text">
<div class="row wow fadeIn">
<div class="col-md-6 mb-4">
<img src="{{ item.image.url }}" class="img-fluid mt-4" alt="">
</div>
<div class="col-md-6 mb-4 information">
<!--Content-->
<div class="p-4 content">
<div class="mt-0">
<h2><u>{{ item.title }}</u><span class="badge badge-{{ item.label_colour }} ml-2">{{
item.labels }}</span></h2>
</div>
<div class="lead">
{% if item.description %}
<h5>{{ item.description }}</h5>
{% endif %}
<h3>P{{ item.price }} per order of {{ item.pieces}} pieces</h3>
<h4>{{ item.instructions }}</h4>
</div>
<a href="{% url 'main:add-to-cart' item.slug %}" class="btn btn-success btn-md my-0 p">Add
to cart</a>
</div>
</div>
<hr>
</div>
</main>
<div class="container">
<h1 class="text-center">Reviews</h1>
<form action="{% url 'main:add_reviews' %}" method="POST" class="mb-3">
{% csrf_token %}
<div class="row">
<div class="col-sm-11">
<input type="text" name="review" class="form-control" placeholder="Enter Your Review">
<input type="hidden" name="rslug" class="form-control" value="{{item.slug}}">
</div>
<div class="col-sm-1">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
{% for review in reviews %}
<div class="main-reviews card bg-success mb-3">
<div class="card-body">
<div class="user_details" style="display: flex; border-bottom: 1px solid rgb(31, 30, 30);">
<h3 class="mr-3">{{ review.user.username }} </h3>
<p class="mt-2">{{ review.posted_on }}</p>
</div>
<h4>{{ review.review }}</h4>
</div>
</div>
{% endfor %}
{% endblock content %}
Home.html
{% extends "main/layout.html" %}
{% block content %}
<div class="home bg-danger">
<div id="carouselExampleCaptions" class="carousel slide mb-5" data-ride="carousel"
style="height: 500px;">
<ol class="carousel-indicators">
<li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
</ol>
<div class="carousel-item active">
<img src="../media/grocery.jpg" class="d-block w-100" alt="sushi1" height="500px">
<div class="carousel-caption d-none d-md-block text-dark">
<h1 style="color: rgb(2, 24, 4)">EASY BASKET</h1>
</div>
<div class="carousel-item">
<img src="../media/4.jpg" class="d-block w-100" alt="sushi2" height="500px">
</div>
<div class="carousel-item">
<img src="../media/garantisado.jpg" class="d-block w-100" alt="sushi3" height="500px">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleCaptions" role="button" data-
slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleCaptions" role="button" data-
slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a
</div>
<div class="container">
<h1 class="text-center text-light mb-3">ITEMS</h1>
<div class="row">
{% for item in menu_items %}
<div class="col-sm-4">
<div class="card mb-3" style="height: fit-content; overflow: auto;">
<img src="{{ item.image.url }}" style="height: 250px;">
<div class="card-body text-center">
<button class="btn btn-warning">By:{{ item.created_by }}</button>
<h5 class="text-center"><a href="{% url 'main:dishes' item.slug %}">{{ item.title }}
</a><span class="badge badge-{{ item.label_colour }}">{{ item.labels }}</span></h5>
<p class="text-center">{{ item.description }}</p>
<h5 class="text-center">P{{ item.price }}</h5>
<a href="{% url 'main:dishes' item.slug %}" class="btn btn-success">View Details</a>
</div>
{% endfor %}
</div>
</div>
</div>
{% endblock content %}
Item_confirmdelete.html
{% extends "main/layout.html" %}
{% block content %}
<div class="content-section container">
<form method="POST">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Delete Item</legend>
<h2>Are you sure you want to delete the post "{{ item.title }}"</h2>
</fieldset>
<div class="form-group">
{% endblock content %}
Item_form.html
{% extends "main/layout2.html" %}
{% load crispy_forms_tags %}
{% block content %}
<div class="form">
<div class="container">
<div class="row">
<div class="col-sm-12">
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Add Item</legend>
{{ form|crispy }}
</fieldset>
<div class="form-group">
<button class="btn btn-primary" type="submit">Add</button>
</div>
</form>
</div>
</div>
{% endblock content %}
Item_list.html
{% extends "main/layout2.html" %}
{% block content %}
<div class="cart">
<div class="row">
<div class="col-sm-12">
{% if items %}
<div class="table-responsive">
<table class="table table-dark">
<thead>
<tr>
<td scope="col">Item No.</td>
<th scope="col">Title</th>
<th scope="col">Decription</th>
<th scope="col">Instructions</th>
<th scope="col">Price</th>
<th scope="col">Pieces</th>
<th></th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.title }} <span class="badge badge-{{ item.label_colour }}">{{
item.labels }}</span></td></td>
<td>{{ item.description }}</td>
<td>{{ item.instructions }}</td>
<td>{{ item.price }}</td>
<td>{{ item.pieces }} pieces</td>
<td><a class="btn btn-primary" href="{% url 'main:item-update' item.slug
%}">Update</a></td>
<td><a class="btn btn-danger" href="{% url 'main:item-delete' item.slug
%}">Delete</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<h4 class="text-center">Sorry, you have not ordered any item yet!!!</h4>
{% endif %}
</div>
</div>
{% endblock content %}
Layout1.html
{% load get_group %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-
Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{% static 'main/styles.css' %}">
<title>ONLINE SHOPPING</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="/"><h3>GROCERY ONLINE SHOPPING</h3></a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNav"
aria-controls="navbarNav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mr-auto">
</ul>
<ul class="navbar-nav ml-auto">
<li><a href="{% url 'main:home' %}" class="mr-2 text-light">Home</a></li>
{% if user.is_authenticated %}
{% if request.user|has_group:"admin_owner" %}
<li><a href="{% url 'main:admin_dashboard' %}" class="mr-2 text-
light">DashBoard</a></li>
<li>
<form class="logout-link" action="{% url 'accounts:logout' %}" method="post">
{% csrf_token %}
<button type="submit" class="mr-2">Logout</button>
</form>
</li>
{% else %}
„
<li><a href="{% url 'main:cart' %}" class="mr-2 text-light">My Cart˙ </a></li>
<li><a href="{% url 'main:order_details' %}" class="mr-2 text-light">Your
Orders</a></li>
<li>
<form class="logout-link" action="{% url 'accounts:logout' %}" method="post">
{% csrf_token %}
<button type="submit" class="mr-2">Logout</button>
</form>
</li>
{% endif %}
{% else %}
<li><a href="{% url 'accounts:login' %}" class="mr-2 text-light">Login</a></li>
$('.carousel').carousel();
</script>
Order_details.html
{% extends "main/layout.html" %}
{% block content %}
<div class="cart">
<div class="container">
<div class="row">
<div class="col-sm-12 mt-5">
<h3 class="text-center">Active Orders</h3>
{% if items %}
<h4 class="text-center">Total Bill Amount: {{total}} for {{ count }} Orders.</h4>
<h6 class="text-center">Please Pay Either via ATM or Credit Card or Cash on Delivery!</h6>
<div class="table-responsive">
<table class="table table-light">
<thead>
<tr>
<th scope="col">Ordered</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Specification</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>
<th scope="col">Order Status</th>
</tr>
</thead>
<tbody>
{% for item_active in items %}
<tr>
<td>{{ item_active.ordered_date }}</td>
<td>{{ item_active.item.title }} <span class="badge badge-{{
item_active.item.label_colour }}">{{ item_active.item.labels }}</span></td>
<td>{{ item_active.item.description }}</td>
<td>{{ item_active.item.instructions }}</td>
<td>{{ item_active.item.price }}</td>
<td>{{ item_active.item.pieces }} pieces</td>
<td>{{ item_active.status }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<h4 class="text-center">Sorry, you have not ordered any item yet!!!</h4>
{% endif %}
</div>
</div>
<div class="row">
<div class="col-sm-12 mt-5">
<h3 class="text-center">Past Orders</h3>
{% if cart_items %}
<div class="table-responsive">
<table class="table table-light">
<thead>
<tr>
<th scope="col">Ordered</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>
<th scope="col">Order Status</th>
<th scope="col">Delivery Date</th>
</tr>
</thead>
<tbody>
{% for cart in cart_items %}
<tr>
<td>{{ cart.ordered_date }}</td>
<td>{{ cart.item.title }} <span class="badge badge-{{ cart.item.label_colour
}}">{{ cart.item.labels }}</span></td>
<td>{{ cart.item.description }}</td>
<td>{{ cart.item.instructions }}</td>
<th scope="col">Specification</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.user.username }}</td>
<td>{{ item.user.email}}</td>
<td>{{ item.item.title }} <span class="badge badge-{{ item.item.label_colour }}">
item.item.labels }}</span></td>
<td>{{ item.item.description }}</td>
<td>{{ item.item.instructions }}</td>
<td>{{ item.item.price }}</td>
<td>{{ item.item.pieces }} pieces</td>
<td>{{ item.status }}</td>
<td>
<form method="POST" action="{% url 'main:update_status' item.id %}" style="display:
flex;">
{% csrf_token %}
<select class="form-control" name="status">
<option value="Active" selected="selected">Active</option>
<option value="Delivered">Delivered</option>
</select>
<button type="submit" class="btn btn-primary">Change</button>
</form>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<h4 class="text-center">Sorry, you have not ordered any item yet!!!</h4>
{% endif %}
</div>
</div>
</div>
{% endblock content %}
Styles.css
.dishes .main .container .row img{
max-width: 540px;
max-height: 450px;
width: fit-content;
}
.dishes .main .container .row .content{
display: flex;
flex-direction: column;
text-align: center;
justify-content: center;
}
.dishes .main .container .row .information{
display: flex;
flex-direction: column;
text-align: center;
justify-content: center;
}
Django Code
settings.py
Django settings for Foods_Ordering project.
Generated by 'django-admin startproject' using Django 3.0.4.
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath( file )))
SECRET_KEY = 'v7)ouo@=dhswvnfs!@o$v07^m#+2l^1+c#n%bel2eqn!5f^fx^'
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main.apps.MainConfig',
'accounts.apps.AccountsConfig',
'crispy_forms',
]
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 = 'Foods_Ordering.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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.messages',
],
},
},
]
WSGI_APPLICATION = 'Foods_Ordering.wsgi.application'
Create database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
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
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
CRISPY_TEMPLATE_PACK = 'bootstrap4'
Urls.py
Foods_Ordering URL Configuration
The `urlpatterns` list routes URLs to views.
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
admin.site.site_header = "Login Administrator"
admin.site.site_title = "Food-Ordering"
admin.site.index_title = "Food Ordering Admin Site"
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('main.urls')),
path('accounts/', include('accounts.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
wsgi.py
WSGI config for Foods_Ordering project. It exposes the WSGI callable as a module-level variable
named ``application``.
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Foods_Ordering.settings')
application = get_wsgi_application()
Asgi.py
ASGI config for Foods_Ordering project. It exposes the ASGI callable as a module-level variable
named ``application``.
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Foods_Ordering.settings')
application = get_asgi_application()
ADMIN.PY
from django.contrib import adminfrom .models
import Item, CartItems, Reviews
from django.db
import models
class ItemAdmin(admin.ModelAdmin):
fieldsets = [
("Created By", {'fields': ["created_by"]}),
("Title", {'fields': ["title"]}),
("Image", {'fields': ["image"]}),
("Description", {'fields': ["description"]}),
("Price", {'fields': ["price"]}),
("Pieces", {'fields': ["pieces"]}),
("Instructions", {'fields': ["instructions"]}),
("Labels", {'fields': ["labels"]}),
forms.py
from django import forms
from .models import Item
class AddForm(forms.ModelForm):
class Meta:
model = Item
fields = ('created_by',
'title', 'image', 'description', 'price', 'pieces', 'instructions', 'labels', 'label_colour', 'slug')
Models.py
from django.db import models
from django.conf import settings
from django.shortcuts import reverse
from django.utils import timezone
from django.contrib.auth.models import User
class Item(models.Model):
LABELS = (
('Best Selling Foods', 'Best Selling Foods'),
('New Food', 'New Food'),
µ
('Spicy Foods˛ ˛
f ', 'Spicy Foodsµ
f '),
)
LABEL_COLOUR = (
('danger', 'danger'),
('success', 'success'),
('primary', 'primary'),
('info', 'info'),
('warning', 'warning'),
)
title = models.CharField(max_length=150)
description = models.CharField(max_length=250,blank=True)
price = models.FloatField()
pieces = models.IntegerField(default=6)
instructions = models.CharField(max_length=250,default="Available")
image = models.ImageField(default='default.png', upload_to='images/')
class CartItems(models.Model):
ORDER_STATUS = (
('Active', 'Active'),
('Delivered', 'Delivered')
)
user = models.ForeignKey(User, on_delete=models.CASCADE)
item = models.ForeignKey(Item, on_delete=models.CASCADE)
ordered = models.BooleanField(default=False)
quantity = models.IntegerField(default=1)
ordered_date = models.DateField(default=timezone.now)
status = models.CharField(max_length=20, choices=ORDER_STATUS, default='Active')
delivery_date = models.DateField(default=timezone.now)
class Meta:
verbose_name = 'Cart Item'
verbose_name_plural = 'Cart Items'
def str (self):
return self.item.title
def get_remove_from_cart_url(self):
return reverse("main:remove-from-cart", kwargs={
'pk' : self.pk
})
def update_status_url(self):
return reverse("main:update_status", kwargs={
'pk' : self.pk
})
Urls.py
from django.urls import path
from . import views
from .views import (
MenuListView, menuDetail, add_to_cart, get_cart_items, order_item, CartDeleteView,
order_details, admin_view, item_list, pending_orders, ItemCreateView, ItemUpdateView,
ItemDeleteView, update_status,add_reviews,
)
app_name = "main"
urlpatterns = [
path('', MenuListView.as_view(), name='home'),
path('dishes/<slug>', views.menuDetail, name='dishes'),
path('item_list/', views.item_list, name='item_list'),
path('item/new/', ItemCreateView.as_view(), name='item-create'),
path('item-update/<slug>/', ItemUpdateView.as_view(), name='item-update'),
path('item-delete/<slug>/', ItemDeleteView.as_view(), name='item-delete'),
path('add-to-cart/<slug>/', views.add_to_cart, name='add-to-cart'),
path('cart/', views.get_cart_items, name='cart'),
path('remove-from-cart/<int:pk>/', CartDeleteView.as_view(), name='remove-from-cart'),
path('ordered/', views.order_item, name='ordered'),
path('order_details/', views.order_details, name='order_details'),
path('admin_view/', views.admin_view, name='admin_view'),
path('pending_orders/', views.pending_orders, name='pending_orders'),
path('admin_dashboard/', views.admin_dashboard, name='admin_dashboard'),
path('update_status/<int:pk>', views.update_status, name='update_status'),
]
Views.py
from django.shortcuts import render, get_object_or_404, redirect
from .models import Item, CartItems, Reviews
from django.contrib import messages
from django.views.generic import (
ListView,
DetailView,
CreateView,
UpdateView,
DeleteView,
)
from django.utils import timezone
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from .decorators import *
form.instance.created_by = self.request.user
return super().form_valid(form)
def test_func(self):
item = self.get_object()
if self.request.user == item.created_by:
return True
return False
class ItemDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView):
model = Item
success_url = '/item_list'
def test_func(self):
item = self.get_object()
if self.request.user == item.created_by:
return True
return False
def add_to_cart(request, slug):
item = get_object_or_404(Item, slug=slug)
cart_item = CartItems.objects.create(
item=item,
user=request.user,
ordered=False,
)
messages.info(request, "Added to Cart!!Continue Shopping!!")
return redirect("main:cart")
def get_cart_items(request):
cart_items = CartItems.objects.filter(user=request.user,ordered=False)
bill = cart_items.aggregate(Sum('item price'))
number = cart_items.aggregate(Sum('quantity'))
pieces = cart_items.aggregate(Sum('item pieces'))
total = bill.get("item price sum")
count = number.get("quantity sum")
total_pieces = pieces.get("item pieces sum")
context = {
'cart_items':cart_items,
'total': total,
'count': count,
'total_pieces': total_pieces
}
return render(request, 'main/cart.html', context)
class CartDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView):
model = CartItems
success_url = '/cart'
def test_func(self):
cart = self.get_object()
if self.request.user == cart.user:
return True
return False
def order_item(request):
cart_items = CartItems.objects.filter(user=request.user,ordered=False)
ordered_date=timezone.now()
cart_items.update(ordered=True,ordered_date=ordered_date)
messages.info(request, "Item Ordered")
return redirect("main:order_details")
def order_details(request):
items = CartItems.objects.filter(user=request.user, ordered=True,status="Active").order_by('-
ordered_date')
cart_items = CartItems.objects.filter(user=request.user,
ordered=True,status="Delivered").order_by('-ordered_date')
bill = items.aggregate(Sum('item price'))
number = items.aggregate(Sum('quantity'))
pieces = items.aggregate(Sum('item pieces'))
total = bill.get("item price sum")
count = number.get("quantity sum")
total_pieces = pieces.get("item pieces sum")
context = {
'items':items,
'cart_items':cart_items,
'total': total,
'count': count,
'total_pieces': total_pieces
}
return render(request, 'main/order_details.html', context)
def admin_view(request):
cart_items = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Delivered").order_by('-ordered_date')
context = {
'cart_items':cart_items,
}
return render(request, 'main/admin_view.html', context)
def item_list(request):
items = Item.objects.filter(created_by=request.user)
context = {
'items':items
}
return render(request, 'main/item_list.html', context)
def update_status(request,pk):
if request.method == 'POST':
status = request.POST['status']
cart_items = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Active",pk=pk)
delivery_date=timezone.now()
if status == 'Delivered':
cart_items.update(status=status, delivery_date=delivery_date)
return render(request, 'main/pending_orders.html')
def pending_orders(request):
items = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Active").order_by('-ordered_date')
context = {
'items':items,
}
return render(request, 'main/pending_orders.html', context)
def admin_dashboard(request):
cart_items = CartItems.objects.filter(item created_by=request.user, ordered=True)
pending_total = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Active").count()
completed_total = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Delivered").count()
count1 = CartItems.objects.filter(item created_by=request.user, ordered=True,item="3").count()
count2 = CartItems.objects.filter(item created_by=request.user, ordered=True,item="4").count()
count3 = CartItems.objects.filter(item created_by=request.user, ordered=True,item="5").count()
total = CartItems.objects.filter(item created_by=request.user,
ordered=True).aggregate(Sum('item price'))
income = total.get("item price sum")
context = {
'pending_total' : pending_total,
'completed_total' : completed_total,
'income' : income,
'count1' : count1,
'count2' : count2,
'count3' : count3,
}
return render(request, 'main/admin_dashboard.html', context)
Migrations.py
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Item',
fields=[
('quantity', models.IntegerField(default=1)),
('specifications', models.CharField(default='Non-Jain/Medium Spicy', max_length=200)),
('delivery_date', models.DateField(default=django.utils.timezone.now, max_length=100)),
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to='main.Item')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL)),
],
),
]
Remove_cartitems.py
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0002_cartitems'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='delivery_date',
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0003_remove_cartitems_delivery_date'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='specifications',
),
]
],
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0006_order'),
]
operations = [
migrations.RenameField(
model_name='order',
old_name='cart',
new_name='cart_items',
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0008_auto_20200726_0216'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='instructions',
),
]
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('main', '0009_remove_cartitems_instructions'),
]
operations = [
migrations.AddField(
model_name='cartitems',
name='ordered_date',
field=models.DateField(default=datetime.datetime(2020, 7, 25, 21, 24, 20, 14250,
tzinfo=utc)),
),
]
Auto.py
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('main', '0010_cartitems_ordered_date'),
]
operations = [
migrations.AlterField(
model_name='cartitems',
name='ordered_date',
field=models.DateField(default=django.utils.timezone.now),
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0012_auto_20200726_2347'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='status',),
]
Cartiems.py
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0013_remove_cartitems_status'),
]
operations = [
migrations.AddField(
model_name='cartitems',
name='status',
field=models.CharField(blank=True, max_length=20),
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0014_cartitems_status'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='status',
),
]
Cart_itemsstatus.py
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0015_remove_cartitems_status'),
]
operations = [
migrations.AddField(
model_name='cartitems',
name='status',
field=models.CharField(choices=[('Active', 'Active'), ('Delivered', 'Delivered')],
default='Active', max_length=20),
),
]
Cartitems_deliverydate.py
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('main', '0016_cartitems_status'),
]
operations = [
migrations.AddField(
model_name='cartitems',
name='delivery_date',
field=models.DateField(default=django.utils.timezone.now),
),
]
Items.py
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('main', '0017_cartitems_delivery_date'),
]
operations = [
migrations.AddField(
model_name='item',
name='created_by',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL),
preserve_default=False,
),
]
Reviews.py
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('main', '0018_item_created_by'),
]
operations = [
migrations.CreateModel(
name='Reviews',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
verbose_name='ID')),
('rslug', models.SlugField(default='sushi-slug')),
('review', models.TextField()),
('posted_on', models.DateField(default=django.utils.timezone.now)),
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to='main.Item')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL)),
],
),
]
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0019_reviews'),
]
operations = [
migrations.AlterField(
model_name='reviews',
name='rslug',
field=models.SlugField(),
),
]
Manage.py
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Foods_Ordering.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()
Creating a basic table involves naming the table and defining its columns and each column's
data type.
The SQL CREATE TABLE statement is used to create a new table.
Syntax
The basic syntax of the CREATE TABLE statement is as follows −
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY (one or more columns)
);
CREATE TABLE is the keyword telling the database system what you want to do. In this
case, you want to create a new table. The unique name or identifier for the table follows the
CREATE TABLE statement.
Then in brackets comes the list defining each column in the table and what sort of data type
it is.
1. Creation of table auth_group
(
id INTEGER,
group_id INTEGER,
permission_id INTEGER,
PRIMARY KEY(id)
);
last_name VARCHAR(150),
PRIMARY KEY(id, email),
FOREIGN KEY(id) REFERENCES auth_permission(id),
FOREIGN KEY(password) REFERENCES auth_permission(codename)
);
change_message TEXT,
content_type_id INTEGER,
user_id INTEGER,
action_flag SMALLINT UNSIGNED,
PRIMARY KEY(id),
FOREIGN KEY(content_type_id) REFERENCES content_type(id)
);
ordered BOOL,
quantity INTEGER,
item_id INTEGER,
user_id INTEGER,
ordered_date DATE,
status VARCHAR(20),
delivery_date DATE,
FOREIGN KEY(id) REFERENCES main_items(id),
FOREIGN KEY(user_id) REFERENCES auth_user(id)
);
4.4.4 Triggers
The SQL INSERT INTO Statement is used to add new rows of data to a table in the database.
Syntax
There are two basic syntaxes of the INSERT INTO statement which are shown below.
INSERT INTO TABLE_NAME (column1, column2, column3,...columnN)
VALUES (value1, value2, value3,...valueN);
Here, column1, column2, column3,...columnN are the names of the columns in the table into
which you want to insert the data.
You may not need to specify the column(s) name in the SQL query if you are adding values
for all the columns of the table. But make sure the order of the values is in the same order as
the columns in the table.
CHAPTER 5
SOFTWARE TESTING
Software Testing is a method to check whether the actual software product matches expected
requirements and to ensure that software product is Defect free. It involves execution of
software/system components using manual or automated tools to evaluate one or more
properties of interest. The purpose of software testing is to identify errors, gaps or missing
requirements in contrast to actual requirements.
2. Error displayed on signup page when user tries to add a new user whose name already exists.
CHAPTER 6
SNAPSHOTS
CHAPTER 7
CONCLUSION AND FUTURE ENHANCEMENT
7.1 Conclusion
The need for online grocery management system has emerged because of change in working
conditions over the last decade with both partners working for long hours. Also, with
urbanization and soaring land prices, it has become difficult to find large amount of land
within cities like Mumbai, Delhi to open large stores.
Hence, the new hyper-local markets are being opened in outer areas resulting in the
increased distances that one has to travel to get to hyper-local store. This coupled with long
billing queues leave little time for people to shop on stores.
The ubiquitous presence of Internet has made it possible for the grocery stores to go online
and has resulted in growth of e-tailing. Keeping this in mind an online grocery management
system has been developed which has both admin and customer side where customer can
place orders or buy groceries by just a tap in computer or mobiles. It also helps the admin to
keep track of the orders and items made available for users to purchase.
In this project future plans are to improve GUI and add a search tab which allows the users to
easily search for groceries rather than scrolling down in search of items.
We are also planning to planning to add a weekly or monthly tab option which will contain the
groceries required per week or per month, thus allowing the user to order the groceries by just
one click.
REFERENCES
Concepts:
• www.stackoverflow.com
• www.guru99.com
• www.w3schools.com
• www.geeksforgeeks.com
• www.github.com
Books:
• Database System Models, Languages, Ramez Elmasri and Sham Kant B. Navathe, 7th