Aman Seminar Report
Aman Seminar Report
Aman Seminar Report
ON
Submitted to:
Submitted By:
Aman Mishra (16EARCS022)
Session: 2019-2020
CERTIFICATE
This is to certify that Aman Mishra (16EARCS022) has successfully delivered Seminar to satisfaction and
report is submitted for partial fulfillment of requirement for the award of degree of Bachelor of Technology
in Computer Science & Engineering under Rajasthan Technical University, Kota.
Seminar Cordinator
Er. Jaideep Manocha
I would like to thank sincerely to my guide Er. Jaideep Manocha for his invaluable guidance,
constant assistance, support and constructive suggestions for the betterment of the technical
seminar. I would like to convey my heartfelt thanks to our Head of Department Dr. Akhil
Pandey for giving me the opportunity to embark upon this topic and for his continued
encouragement throughout the preparation of this presentation. I also want to thank all the
staff members of the department of Computer Engineering for helping directly or indirectly in
completing this work successfully. Finally, I am thankful to my parents and friends for their
continued moral and material support throughout the course and in helping me finalize the
report.
Aman Mishra
final year 8th semester (16EARCS022)
Department of Computer Engineering
Arya College of Engineering & I.T., Jaipur
LIST OF CONTENTS
1. INTRODUCTION
1.1 What is Python …………………………………………………
1.2 Why is so Popular
1.3 In which field python is used
(A) Console based applications
(B)Web applications
2. Web Development
2.1 Introduction to web development with python………………………………..
2.2 Introduction to Django………………………………………………………...
2.3 Why Django is so popular…………………………………………………….
The objective of this briefing is to present an overview of the python currently in use in web
applications , mobile applications , desktop applications. Section I, outlines the main reason
why python is so popular and why it is more useful. discuss current research or applications
of python within the field of official statistics in the areas of automatic coding, editing and
imputation, and record linkage, respectively. The material presented in this report is the result
of a literature review, of direct contacts with authors during conferences, and more
importantly of an international call for input that was distributed on July 18, 2014 to
participants from the 2014 MSIS Meeting, participants from the 2014 Work Session on
Statistical Data Editing, and members of the Modernization Committee on Production and
Methods.
INTRODUCTION TO TOPIC
What is python?
Python is an interpreted high level , general purpose programming language created by guido van rossum
and first released in 1991. Python's design philosphy emphasized code readability with notable used of
significance whitespace.
Python was conceived in the late 1980 as successor to abc language.
According to the latest TIOBE Programming Community Index, Python is one of the top 10 popular
programming languages of 2017. Python is a general purpose and high level programming language. You can
use Python for developing desktop GUI applications, websites and web applications. Also, Python, as a high
level programming language, allows you to focus on core functionality of the application by taking care of
common programming tasks.
Why is so popular
Consol applications
A console application is a computer program designed to be used via a text-only computer interface, such as a
text terminal, the command line interface of some operating systems (Unix, DOS, etc.) or the text-based
interface included with most Graphical User Interface (GUI) operating systems, such as the Win32 console in
Microsoft Windows, the Terminal in Mac OS X, and xterm in Unix. A user typically interacts with a console
application using only a keyboard and display screen, as opposed to GUI applications, which normally require
the use of a mouse or other pointing device. Many console applications such as command line interpreters are
command line tools, but numerous text-based user interface (TUI) programs also exist.
As the speed and ease-of-use of GUIs applications have improved over time, the use of console applications
has greatly diminished, but not disappeared. Some users simply prefer console based applications, while some
organizations still rely on existing console applications to handle key data processing tasks.
The ability to create console applications is kept as a feature of modern programming environments such as
Visual Studio and the .NET Framework on Microsoft Windows because it greatly simplifies the learning process
of a new programming language by removing the complexity of a graphical user interface (see an example in
the C# article).
For data processing tasks and computer administration, these programming environments represent the next
level of operating system or data processing control after scripting. If an application is only going to be run by
the original programmer and/or a few colleagues, there may be no need for a pretty graphical user interface,
leaving the application leaner, faster and easier to maintain.
Console-based applications include Alpine (an e-mail client), cmus (an audio player), Irssi (an IRC client), Lynx
(a web browser), Midnight Commander (a file manager), Music on Console (an audio player), Mutt (an e-mail
client), nano (a text editor), ne (a text editor), newsbeuter (an RSS reader), and ranger (a file manager).
GUI applications
python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods,
tkinter is most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with
Python. Python with tkinter outputs the fastest and easiest way to create the GUI applications. Creating a GUI
To create a tkinter:
6. Importing the module – tkinter
7. Create the main window (container)
8. Add any number of widgets to the main window
9. Apply the event Trigger on the widgets.
Importing tkinter is same as importing any other module in the python code. Note that the name of the module
in Python 2.x is ‘Tkinter’ and in Python 3.x is ‘tkinter’.
filter_none
edit
play_arrow
brightness_4
import tkinter as tk
r = tk.Tk()
r.title('Counting Seconds')
button = tk.Button(r, text='Stop', width=25, command=r.destroy)
button.pack()
r.mainloop()
Output:
19. Canvas: It is used to draw pictures and other complex layout like graphics, text and widgets.
The general syntax is:w = Canvas(master, option=value)master is the parameter used to
represent the parent window.
20. There are number of options which are used to change the format of the widget. Number of options
can be passed as parameters separated by commas. Some of them are listed below.
bd: to set the border width in pixels.
bg: to set the normal background color.
cursor: to set the cursor used in the canvas.
highlightcolor: to set the color shown in the focus highlight.
width: to set the width of the widget.
height: to set the height of the widget.
filter_none
edit
play_arrow
brightness_4
from tkinter import *
master = Tk()
w = Canvas(master, width=40, height=60)
w.pack()
canvas_height=20
canvas_width=200
y = int(canvas_height / 2)
w.create_line(0, y, canvas_width, y )
mainloop()
Output:
21. CheckButton: To select any number of options by displaying a number of options to a user as toggle
buttons. The general syntax is:w = CheckButton(master, option=value)
22. There are number of options which are used to change the format of this widget. Number of options
can be passed as parameters separated by commas. Some of them are listed below.
Title: To set the title of the widget.
activebackground: to set the background color when widget is under the cursor.
activeforeground: to set the foreground color when widget is under the cursor.
bg: to set he normal backgroudSteganography
Break
Secret Code:
Attach a File:nd color.
command: to call a function.
font: to set the font on the button label.
image: to set the image on the widget.
filter_none
edit
play_arrow
Web applications
What is django:-
Django is a Python-based web framework which allows you to quickly create web application without all of the
installation or dependency problems that you normally will find with other frameworks.
When you’re building a website, you always need a similar set of components: a way to handle user
authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to
upload files, etc. Django gives you ready-made components to use.
Why Django?
23. It’s very easy to switch database in Django framework.
24. It has built-in admin interface which makes easy to work with it.
25. Django is fully functional framework that requires nothing else.
26. It has thousands of additional packages available.
27. It is very scalable.
Popularity of Django
Django is used in many popular sites like as: Disqus, Instagram, Knight Foundation, MacArthur Foundation,
Mozilla, National Geographic etc. There are more than 5k online sites based on the Django framework. ( Source
)
Sites like Hot Frameworks assess the popularity of a framework by counting the number of GitHub projects
and StackOverflow questions for each platform, here Django is in 6th position. Web frameworks often refer to
themselves as “opinionated” or “un-opinionated” based on opinions about the right way to handle any particular
task. Django is somewhat opinionated, hence delivers the in both worlds( opinionated & un-opinionated ).
Some features of Django
Versatility of Django
Django can build almost any type of website. It can also work with any client-side framework and can deliver
content in any format such as HTML, JSON, XML etc. Some sites which can be built using Django are wikis,
social networks, new sites etc.
Security
Since Django framework is made for making web development easy, it has been engineered in such a way that
it automatically do the right things to protect the website. For example, In the Django framework instead of
putting a password in cookies, the hashed password is stored in it so that it can’t be fetched easily by hackers.
Scalability
Django web nodes have no stored state, they scale horizontally – just fire up more of then when you need them.
Being able to do this is the essence of good scalability. Instagram and Disqus are two Django based products
that have millions of active users, this is taken as an example of the scalability of Django.
Portability
All the codes of the Django framework are written in Python, which runs on many platforms. Which leads to
run Django too in many platforms such as Linux, Windows and Mac OS.
Installation of Django
Install python3 if not installed in your system ( according to configuration of your system and OS)
from here . Try to download the latest version of python it’s python3.6.4 this time.
Note- Installation of Django in Linux and Mac is similar, here I am showing it in windows for Linux
and mac just open terminal in place of command prompt and go through the following commands.
Install pip- Open command prompt and enter following command-
python -m pip install -U pip
Install virtual environment- Enter following command in cmd-
pip install virtualenv
Set Virtual environment- Setting up the virtual environment will allow you to edit the dependency
which generally your system wouldn’t allow.
Follow these steps to set up a virtual environment-
27.1 Create a virtual environment by giving this command in cmd-virtualenv env_site
27.2
27.3 Change directory to env_site by this command-cd env_site
27.4
27.5
27.6 Go to Script directory inside env_site and activate virtual environment-cd Scriptactivate
27.7
Install Django- Install django by giving following command-pip install django
Return to the env_site directory-cd ..
Start a project by following command-django-admin startproject geeks_site
Change directory to geeks_sitecd geeks_site
Start the server- Start the server by typing following command in cmd-python manage.py
runserver
Django
Django is a Python-based web framework which allows you to quickly create web application without all of the
installation or dependency problems that you normally will find with other frameworks.
When you’re building a website, you always need a similar set of components: a way to handle user
authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to
upload files, etc. Django gives you ready-made components to use.
CHAPTER 4
The project, Hotel Management System is a web-based application that allows the hotel manager to
handle all hotel activities online. Interactive GUI and the ability to manage various hotel bookings and
rooms make this system very flexible and convenient. Customers can view and book room online.
In this project front end is designed using Django and in back end SQlite3 is used.
Front page
Check in
Show guest list
Check out
Get information of guest exit
The software project contributors are required to install the dependencies as follows:
Create a virtual environment as (you can use any name of the environment as you like):
source hms-virtual-env/bin/activate
Finally:
Front page
Front page: coding
Check in
Recipt
Check out
Get info of guest
Code:-
admin.py
@admin.register(Staff)
class StaffAdmin(admin.ModelAdmin):
list_display = (
'staff_id',
'user',
'first_name',
'middle_name',
'last_name',
'contact_no',
'address',
'email_address',
search_fields = [
'staff_id',
'user',
'first_name',
'middle_name',
'last_name',
'contact_no',
'address',
'email_address',
fieldsets = (
(None, {
}),
('Contact Information', {
})
@admin.register(Customer)
class CustomerAdmin(admin.ModelAdmin):
list_display = (
'customer_id',
'first_name',
'middle_name',
'last_name',
'contact_no',
'address',
'email_address',
search_fields = [
'customer_id',
'first_name',
'middle_name',
'last_name',
'contact_no',
'address',
'email_address',
fieldsets = (
(None, {
('Contact Information', {
})
@admin.register(Reservation)
class ReservationAdmin(admin.ModelAdmin):
list_display = (
'reservation_id',
'customer',
'staff',
'no_of_children',
'no_of_adults',
'reservation_date_time',
'expected_arrival_date_time',
'expected_departure_date_time',
)
@admin.register(Room)
class RoomAdmin(admin.ModelAdmin):
list_display = (
'room_no',
'room_type',
'reservation',
'availability',
'display_facility',
# Adding filter
filter_horizontal = ('facility',)
search_fields = [
'reservation__customer__first_name',
'reservation__customer__middle_name',
'reservation__customer__last_name',
]
@admin.register(Facility)
class FacilityAdmin(admin.ModelAdmin):
@admin.register(RoomType)
class RoomTypeAdmin(admin.ModelAdmin):
views.py
def index(request):
"""
"""
total_num_rooms = Room.objects.all().count()
available_num_rooms = Room.objects.exclude(reservation__isnull=False).count()
total_num_reservations = Reservation.objects.all().count()
total_num_staffs = Staff.objects.all().count()
total_num_customers = Customer.objects.all().count()
if total_num_reservations == 0:
last_reserved_by = Reservation.objects.none()
else:
last_reserved_by = Reservation.objects.get_queryset().latest('reservation_date_time')
return render(
request,
'index.html',
'title': page_title,
'total_num_rooms': total_num_rooms,
'available_num_rooms': available_num_rooms,
'total_num_reservations': total_num_reservations,
'total_num_staffs': total_num_staffs,
'total_num_customers': total_num_customers,
'last_reserved_by': last_reserved_by,
}
)
@transaction.atomic
def signup(request):
title = "Signup"
if request.user.is_authenticated:
request.session.flush()
if request.method == 'POST':
form = Signup(request.POST)
if form.is_valid():
try:
with transaction.atomic():
form.save()
staff_id = form.cleaned_data['staff_id']
username = form.cleaned_data['username']
s = get_object_or_404(Staff, staff_id__exact=staff_id)
s.user.groups.add(staffs_group)
s.user.save()
s.save()
except IntegrityError:
raise Http404
return redirect('index')
else:
form = Signup()
return render(
request,
'signup.html', {
@transaction.atomic
def reserve(request):
title = "Add Reservation"
reservation = Reservation.objects.none()
if request.method == 'POST':
reservation_form = ReservationForm(request.POST)
if reservation_form.is_valid():
try:
with transaction.atomic():
customer = Customer(
first_name=reservation_form.cleaned_data.get('first_name'),
middle_name=reservation_form.cleaned_data.get('middle_name'),
last_name=reservation_form.cleaned_data.get('last_name'),
email_address=reservation_form.cleaned_data.get('email'),
contact_no=reservation_form.cleaned_data.get('contact_no'),
address=reservation_form.cleaned_data.get('address'),
customer.save()
staff = request.user
reservation = Reservation(
staff=get_object_or_404(Staff, user=staff),
customer=customer,
no_of_children=reservation_form.cleaned_data.get('no_of_children'),
no_of_adults=reservation_form.cleaned_data.get('no_of_adults'),
expected_arrival_date_time=reservation_form.cleaned_data.get('expected_arrival_date_time'),
expected_departure_date_time=reservation_form.cleaned_data.get('expected_departure_date_time'),
reservation_date_time=timezone.now(),
reservation.save()
room.reservation = reservation
room.save()
except IntegrityError:
raise Http404
return render(
request,
'reserve_success.html', {
'reservation': reservation,
)
else:
reservation_form = ReservationForm()
return render(
request,
'reserve.html', {
'title': title,
'reservation_form': reservation_form,
def reserve_success(request):
pass
# eg room_list, room_detail
# @permission_required('main.can_view_staff')
"""
"""
permission_required = 'main.can_view_room'
# By default:
# template_name = room_list
# if you want to change it, use field template_name
def get_queryset(self):
if filter_value == 'all':
filter_value = 0
filter_value = 1
try:
except ValidationError:
return new_context
return context
class RoomDetailView(PermissionRequiredMixin, generic.DetailView):
"""
"""
model = Room
permission_required = 'main.can_view_room'
"""
"""
model = Reservation
# Here, the objects are displayed by reservation date time in descending order
queryset = Reservation.objects.all().order_by('-reservation_date_time')
paginate_by = 5
allow_empty = True
form_class = CheckInRequestForm
success_url = reverse_lazy('check_in-list')
permission_required = 'main.can_view_reservation'
@transaction.atomic
try:
with transaction.atomic():
checkin = form.save(commit=False)
checkin.user = self.request.user
checkin.save()
except IntegrityError:
raise Http404
return super().form_valid(form)
"""
"""
model = Reservation
permission_required = 'main.can_view_reservation'
raise_exception = True
"""
"""
model = Customer
permission_required = 'main.can_view_customer'
raise_exception = True
"""
"""
model = Staff
permission_required = 'main.can_view_staff_detail'
template_name = 'profile.html'
title = "Profile"
context = super().get_context_data(**kwargs)
if self.request.user.is_authenticated:
context['user_information'] = self.request.user
else:
return context
"""
@transaction.atomic
def reserve(request):
title = "Add reservation"
if request.method == 'POST':
try:
with transaction.atomic():
reservation_form = ReservationForm(request.POST)
try:
with transaction.atomic():
customer = Customer(
first_name=reservation_form.cleaned_data.get('first_name'),
middle_name=reservation_form.cleaned_data.get('middle_name'),
last_name=reservation_form.cleaned_data.get('last_name'),
email_address=reservation_form.cleaned_data.get('email'),
address=reservation_form.cleaned_data.get('address'),
customer.save()
except IntegrityError:
staff = request.user
reservation = reservation_form.save(commit=False)
reservation.staff = staff
reservation.customer = customer
reservation.reservation_date_time = timezone.now()
reservation.save()
except IntegrityError:
else:
reservation_form = ReservationForm()
return render(
request,
'reserve.html', {
'title': title,
'reservation_form': reservation_form,
"""
urls.py
urlpatterns = [
# e.g. if you want to use the hyperlink of index page, don't use hardcoded url like
# to solve this, use the value from name field. for above example use
Models.py
@python_2_unicode_compatible
class Staff(models.Model):
staff_id = models.AutoField(primary_key=True)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
contact_no = models.CharField(max_length=15)
address = models.CharField(max_length=100)
email_address = models.EmailField()
class Meta:
permissions = (("can_view_staff", "Can view staff"), ('can_view_staff_detail', 'Can view staff detail'))
@python_2_unicode_compatible
class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
first_name = models.CharField(max_length=50)
contact_no = models.CharField(max_length=15)
address = models.CharField(max_length=100)
class Meta:
def get_absolute_url(self):
"""
"""
def __str__(self):
class Reservation(models.Model):
reservation_id = models.AutoField(primary_key=True)
no_of_children = models.PositiveSmallIntegerField(default=0)
no_of_adults = models.PositiveSmallIntegerField(default=1)
reservation_date_time = models.DateTimeField(default=timezone.now)
expected_arrival_date_time = models.DateTimeField(default=timezone.now)
expected_departure_date_time = models.DateTimeField(default=timezone.now)
class Meta:
def get_absolute_url(self):
@python_2_unicode_compatible
class Room(models.Model):
availability = models.BooleanField(default=0)
facility = models.ManyToManyField('Facility')
class Meta:
ordering = ['room_no', ]
def __str__(self):
"""
"""
display_facility.short_description = 'Facilities'
def get_absolute_url(self):
self.availability = 0
else:
self.availability = 1
super().save(*args, **kwargs)
@python_2_unicode_compatible
class Facility(models.Model):
name = models.CharField(max_length=25)
price = models.PositiveSmallIntegerField()
class Meta:
def __str__(self):
return self.name
@python_2_unicode_compatible
class RoomType(models.Model):
name = models.CharField(max_length=25)
price = models.PositiveSmallIntegerField()
def __str__(self):
return self.name
templates:-
{% extends 'base.html' %}
{% block content-title %}
{% endblock %}
{% block main-content %}
<div class="container-fluid">
<div class="row">
<div class="panel-body">
{% csrf_token %}
<div class="form-group">
{% endfor %}
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
CHAPTER 5
CONCLUSION
Django is excellent for small, quick web applications, and since it runs on more platforms than any other
Python web development toolkit, it is a good choice where portability is the prime concern.
Obviously we haven’t been able to give Django the depth of discussion it warrants, but it’s fair to say that
almost anything that can be done using the C language and Tk can be done using Python and django. One
example is the Python megawidgets (PMW) package mentioned previously; this is a pure Python package that
creates an excellent widget set by building on the core Django widgets.
REFERENCES
2. Lightweight Django
by Nigel Georg
5.Django Unleashed
by Andrew Pinkham
by Kevin Harvey