NRI INSTITUTE OF
INFORMATION SCIENCE & TECHNOLOGY
SESSION 2019-2020
INDUSTRIAL TRAINING REPORT
ON
“Advanced Python with Django”
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
Submitted By
Nishant Deheriya
(0115CS161050)
RAJIV GANDHI PROUDYOGIKI VISHWAVIDHYALAYA, BHOPAL
0
INDEX
S No Content Page No
1 COMPANY PROFILE 03
2 TRAINING SUMMARY 03
3 ACKNOWLEDGEMENT 04
4 COURSEDESCRIPTION 05
5 LEARNING OUTCOMES 05
6 Python Basic 06
7 VARIABLES TYPES AND 07
PROPRETIES
8 Working with String & 09
List
9 Classes and modulus 10
10 Exception handling in 11
python
11 INTRODUCTION TO 12
DJANGO
12 URLS VIEWS & FORMS 13
13 SESSIONS, USERS, AND 14
REGISTRATION
14 SENDING EMAIL 16
15 MAKE COMPLETE E- 17
COMMERCE
1
Certificate
2
COMPANY PROFILE
TechSim plus is one of the world’s leading training providers. It partners with companies and
Indian Institutes to provide training and coaching helps students and working professionals to
achieve their career goals.
It is a learning platform that provide instructor led classroom training on Industry relevant
technologies like Data Analytics, Deep Learning, Artificial Intelligence, Machine Learning,
Advanced Python with Django, Data Science, IOT &Raspberry Pi- 3, etc.
TRAINING SUMMARY
We have done our Industrial Training on Core+ Advanced Python with Django from
TechSim+, Bhopal by trainers Prateek Mishra and Nikita Choudhary in time duration 15
July to 12 August 2019.
This institute provided me good training focusing mainly on practical knowledge. It also
guided me in making a project “E-Commerce” on Python using Django platform.
3
ACKNOWLEDGEMENT
The internship opportunity I had with “TECHSIM+” was a great chance for learning
andprofessional development. Therefore, I consider myself as a very lucky individual as I
was provided with an opportunity to be a part of it. I am also grateful for having a chance to
meet so many wonderful people and professional who led me though this internship period.
It is my radiant sentiment to place on record my best regards, deepest sense of gratitude to
[Link] MISHRA for their careful and precious guidance which were extremely
valuable for my study both theoretically and practically. I perceive as the opportunity as a big
milestone in my career development.
4
COURSE DESCRIPTION
Python has been one of the premier, flexible, and powerful open-source language and is easy
to learn, easy to use, and has powerful libraries for data manipulation and analysis. For over a
decade, Python has been used in scientific computing and highly quantitative domains such as
finance, oil and gas, physics, and signal processing. The training is a step by step guide to
Python and Django (Web Development) with extensive hands on. The course is packed with
several activity problems and assignments and scenarios that help you gain practical
experience. At the end of this training you will be master in Python and Web Development
with Django.
LEARNING OUTCOMES
Gain insight into the 'Roles' played by a Python Developer.
Get Certified by IIT'S and NIT's.
Work on Real Projects.
Training based Hands on Practical and Projects
Get one year Membership with TechSim +
Placement Opportunity in Core Python Companies
Understand our course’s outline
Know some basic concepts about Python programming language (built in types,
statements, class, Exception Handling,…)
Can write some simple python program
Know the use of Python /Django in today’s world
INSTALLATION & CONFIGURATION-OUTCOMES
Setup successfully according to the guides
Understand Django Structure Directories and functions.
Shopping:
_int.py
[Link]
[Link] Sms:
_int_.py
[Link]
[Link]
[Link] [Link]
5
[Link]
[Link]
CURRICULUM
OVERALL PYTHON /DJANGO COURSE
Section1: Getting familiar with Python/Django
Part1: Introduction to Python/Django
Part2:HTML+CSS
Part3:Installation& Configuration
Section2: Understanding Basics Parts
Part4:Models
Parts5:Querysets
Part6:URL Configuration and Request/Response(Views)
Part7:Django Templates
Section3: Adding functions to your page
Part8:Admine Sites
Part9:Forms
Part10:File Uploads & Generic View
Deployment
STEP - 1: PYTHON BASICS
WHAT IS PYTHON
Python is a programming language used on server to create web applications. Python is
aninterpreted,high-level,general-purposeprogramming languagecreated byGuido Van
Rossumand first released in [Link]'s design emphasizescode readabilitywith its notable
use ofsignificant whitespace. Its language constructs andobject-orientedapproach aim to help
programmers write clear, logical code for small and large-scale are python.
PROGRAMMING LANGUAGE
Python is powerful... and fast; plays well with others; runs everywhere; is friendly & easy to
learn; is Open. These are some of the reasons people who use Python would rather not use
anything else.
GETTING STARTED: DOWNLODING AND INSTALLING
6
Python can be easy to pick up whether you're a first time programmer or you're experienced
with other [Link] pages are a useful first step to get on your way writing programs
with Python! Beginner's Guide, Programme Beginner's Guide, Non-Programmers Beginner's
Guide, Download & Installation Code sample and snippets for Beginners.
Friendly & Easy to Learn :
The community hosts conferences and meet ups, collaborates on code, and much more.
Python's documentation were Conferences
And Workshops Python Documentation Mailing Lists and IRC channels.
Open source:
Python is developed under an OSI-approved open source license, making it freely usable and
distributable, even for commercial use. Python's license is administered by the Python
Software For.
VARIABLES TYPES AND PROPRETIES
SRTINGS
String literals in python are surrounded by either single quotation marks, or double quotation
[Link] can be output to screen using the print function.
For example:
1. >>> x*5
'HelloHelloHelloHelloHello
2. >>> x = 'Hello Python'
>>>x[1] 'e'
>>>x[0] 'H'
>>>x[6] 'P'
>>>x[-1] 'n'
>>>x[-3] 'h'
PROPRITES
Besides numbers, Python can also manipulate strings, which can be expressed in several ways.
They can be enclosed in single quotes ('...') or double quotes ("...") with the same result. \ can
be used to escape quotes:
SLICING
Slicing creates a slice of an object representing the set of indices specified by range (start :
stop : step).
7
x = 'Hello Python >>>
x[4:9] 'o Pyt'
>>>x[6:] 'Python'
>>>x[:9] 'Hello Pyt'
Source code: inp = input('enter an URL ') dom = inp[12:-4] print('Domain
name is :',dom) Output:
enter an URL [Link]
By default split function splits from space ( ), but we can also pass a parameter if we want to
split the string from any particular character.
STRING: LIST AND JOIN FUNCTION:
list() function is used to convert a string into list taking individual character (including space)
as elements. For Example:
>>> x = 'Hello Python'
>>> list(x) ['H', 'e', 'l', 'l', 'o', ' ', 'P', 'y', 't', 'h', 'o', 'n']
join() function is used to join elements of a list to create a whole string.
STEP - 2: CONDITIONAL LOOPS AND STATEMENTS
MAKING DECSICION, FLOW CONTROL
LOGICAL,BOOLEAN EXPRESSION
Python supports the usual logical conditions from mathematics:
• Equals: a = b
• Not Equals: a !== b
• Less than: a < b
• Less than or equal to: a <= b
• Greater than: a > b
• Greater than or equal to: a >= b
LOOPS (WHILE LOOP),BREAK STATEMENT
For loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or
a string).A for loop can execute a set of statements, once for each item in a list, tuple, set.
With the break statement we can stop the loop before it has looped through all the items. With
the continue statement we can stop the current iteration of the loop and continue with the next.
The else keyword in a for loop specifies a block of code to be executed when the loop is
finished.
8
While loop can execute a set of statements as long as a condition is true. The while loop requires
relevant variables to be ready.
Break statement can stop the loop even if the while condition is true.
Continue statement can stop the current iteration and continue with the next iteration.
FACTORIAL USING WHILE LOOP
MULTIPLE ASSIGNMENT
STEP - 3: WORKING WITH STRINGS & LIST
STRUCTURED DATA – LIST
Data Structures This chapter describes some things you’ve learned about already in more detail,
and adds some new things as well.
MORE ON LISTS:
The list data type has some more methods. Here are all of the methods of the lists objects.
List .append (x)
Add an item to the end of the list. Equivalent to a [ len (a) :]=[x]
List .extend(iterable)
Extend the list by appending all the items from the iterable. Equivalent to a [ len (a) :] =
iterable
List .insert(i,x)
Insert an item at a given position. So, a. insert (0,x)
List .remove(x)
Remove the first item from the list whose value is equal to x. it raises a valueError if there is
no such item.
List .pop([i])
Remove the item from the given position in the list, and return it. [Link] () removes and returns
the last item in the list.
LOOP (FOR LOOP) ON LISTS
FOR LOOP:
A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set,
or a string). This is less like the for keyword in other programming languages, and works more
9
like an iterator method as found in other object-orientated programming languages. With the
for loop we can execute a set of statements, once for each item in a list, tuple, set etc.
>>> for i in Name:
print(i) Sourabh
Mahesh
Pranay
Arpit
Lovelesh
Anirudh
ELSE IN FOR LOOP:
The else keyword in a for loop specifies a block of code to be executed when the loop is
finished.
Print all numbers from 0 to 5, and print a message when the loop has ended.
for x in range(6): print(x) else:
print("Finally finished!")
STEP - 4: CLASSES AND MODULES
LAMBDA FUNCTION
Lambda Expressions Small anonymous functions can be created with the lambda keyword.
This function returns the sum of its two arguments: lambda a, b: a+b. Lambda functions can be
used wherever function objects are required. They are syntactically restricted to a single
expression. Semantically, they are just syntactic sugar for a normal function definition. Like
nested function definitions, lambda functions can reference variables from the containing
scope.
>>> def make_incrementor(n):
return lambda x: x + n >>> f =
make_incrementor(42)
>>>f(0) 42
>>>f(1) 43
STRING FORMAT
Method Basic usage of the [Link]() method looks like this:
>>>print('We are the {} who say "{}!"'.format('knights', 'Ni')) We are the knights who say "Ni!"
10
The brackets and characters within them (called format fields) are replaced with the objects
passed into the [Link]() method. A number in the brackets can be used to refer to the position
of the object passed into the [Link]() method.
NESTED FUNCTIONS:
A nested loop is a loop inside a loop.
The "inner loop" will be executed one time for each iteration of the "outer loop":
Example Print each adjective for every fruit: adj = ["red", "big", "tasty"] fruits = ["apple",
"banana", "cherry"] for x in adj: for y in fruits: print(x, y)
The while Loop
Nested List Comprehensions:
The initial expression in a list comprehension can be any arbitrary expression, including another
list comprehension.
Consider the following example of a 3x4 matrix implemented as a list of 3 lists of length 4:
>>> matrix =[1, 2, 3, 4]
[5, 6, 7, 8]
[9, 10, 11, 12]
The following list comprehension will transpose rows and columns:
GENERATOR EXPREESSION
OOP PROGRAMMING
11
STEP - 5: EXCEPTION HANDLING IN PYTHON
UNDERSTANDING EXCEPTION
The try block allow us to test a block of code for errors.
The except block lets you handle the error.
The finally block lets you execute code, regardless of the result of the try and except blocks.
When an error or exception occurs, Python will normally stop and generate an error message.
These exceptions can be handled using the try statement.
Since the try block raises an error, the except block will be executed. Without the try block, the
program will crash and raise an error.
You can use the else keyword to define a block of code to be executed if no errors were raised.
The finally block, if specified, will be executed regardless if the try block raises an error or not.
• STEP - 6: INTRODUCTION TO DJANGO
Required Python Knowledge
Your First View: Dynamic Content
How Django process a Request
404 Error
Django Pretty Error Pages
• STEP - 7: THE DJANGO TEMPLATE SYSTEM
Using the Template System
Multiple Contexts, Same Template
Playing with Context Objects
Template Loading & Inheritance
Using Templates in Views
• STEP - 8: INTERFACING WITH A DATABASE: MODELS
Configuring the Database
Basic Data Access
Inserting and Updating data
Filtering, Ordering & Slicing Data
Adding & Removing Fields
Removing Models
12
STEP - 9: URLS VIEWS & FORMS
Standard URL Configuration
Resolving URLs to Views
Function-Based Views
Binding to User Input
Custom Fields
Fig 1.1 - [Link]
13
Fig 1.2 [Link]
STEP - 10: SESSIONS, USERS, AND REGISTRATION
Users and Authentication
Logging In and Out
Managing Users, Permissions, and Groups
Activating the Admin Interface Customizing Admin Templates
Custom Model Templates
Create Authentication
14
Fig 1.3 [Link]
15
Fig 1.4 [Link]
STEP - 11: SENDING EMAIL
Quick example
Send Mail()
The Email Message class
Email backend
Configuring email for development
16
Fig 1.5 order placed
STEP - 12: MAKE COMPLETE E-COMMERCE
Start Project
Connecting Templates
Make Models
Create Add to Cart
Check Out
Add Payment Method
Integrate Payment Gateway
Integrate SMS Gateway
Add Admin Panel
Add Category and Products
Track New Orders
Make Live your Project
17
Fig 1.6 [Link]
18