0% found this document useful (0 votes)
144 views48 pages

1 Python: Approval II Abstract III

The document discusses the history and features of the Python programming language. It describes how Python was created in the late 1980s by Guido van Rossum based on the ABC language. It then covers Python's key features, including being easy to learn, portable to different platforms, object-oriented, dynamic, and extensible/scalable. The document also provides details on Python's version history from versions 0.9 to 3.0.

Uploaded by

Milan
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)
144 views48 pages

1 Python: Approval II Abstract III

The document discusses the history and features of the Python programming language. It describes how Python was created in the late 1980s by Guido van Rossum based on the ABC language. It then covers Python's key features, including being easy to learn, portable to different platforms, object-oriented, dynamic, and extensible/scalable. The document also provides details on Python's version history from versions 0.9 to 3.0.

Uploaded by

Milan
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/ 48

Contents

Approval ii

Abstract iii

1 Python

1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.2 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.3.1: Very Easy-to-Learn


1.3.2: Ported to Other Platforms
1.3.3: Object- Oriented Language
1.3.4: Dynamic in Nature
1.3.5: Extendable & Scalable

1.4 Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5 Web Frameworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1.5.1 Full Stack Frameworks


1.5.2 Non-Full-Stack Frameworks

2. Django
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.2 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.3.1 Complete

2.3.2 Versatile

2.3.3 Secure

2.3.4 Scalable

2.3.5 Maintainable

2.3.6 Portable
3. Django Architecture and Code

3.1 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3.2 Code Working . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3.3 Other Functionalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4. My Project

4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4.2 Goals

4.3 Usage Scenarios

4.3.1 User Profiles

4.3.2 Use Case

4.3.3 Use Case Diagram

5. Website Overview

5.1 Homepage For Users

5.2 Images Section of the Website

5.3 Services Section of Webpage

5.4 Contact Section of the Website

5.5 Sign up Page of the Website

5.6 OTP verification After Signup

5.7 Login Page of Website

5.8 Forgot password

5.9 Homepage After Login

5.10 GET PG

5.11 POST PG Detail


5.12 Admin Login Screen

5.13 Admin Page After Login

5.14 User Details

5.15 PG Details in Admin Panel


1. Python
1.1 Introduction
Python is an open source, high-level programming language developed by Guido van Rossum in
the late 1980s and presently administered by Python Software Foundation. It came from the ABC
language that he helped create early on in his career. Python is a powerful language that you can
use to create games, write GUIs, and develop web applications. It is a high-level language. Reading
and writing codes in Python is much like reading and writing regular English statements. Because
they are not written in machine-readable language, Python programs need to be processed before
machines can run them. Python is an interpreted language. This means that every time a program
is run, its interpreter runs through the code and translates it into machine-readable byte code.
Python is an object-oriented language that allows users to manage and control data structures or
objects to create and run programs.
Everything in Python is, in fact, first class. All objects, data types, functions, methods, and classes
take equal position in Python. Programming languages are created to satisfy the needs of
programmers and users for an effective tool to develop applications that impact lives, lifestyles,
economy, and society. They help make lives better by increasing productivity, enhancing
communication, and improving efficiency. Languages die and become obsolete when they fail to
live up to expectations and are replaced and superseded by languages that are more powerful.
Python is a programming language that has stood the test of time and has remained relevant across
industries and businesses and among programmers, and individual users. It is a living, thriving,
and highly useful language that is highly recommended as a first programming language for those
who want to dive into and experience programming

1.2 History

When we talk about the history of Python, we cannot miss ABC programming language because
it was ABCs influence that led to the design and development of programming language called
Python.
In the early 1980s, Van Rossum used to work at CWI (Centrum voor Wiskunde en Informatica) as
an implementer of the programming language called ABC. Later at CWI in the late 1980s, while
working on a new distributed operating system called AMOEBA, Van Rossum started looking for
a scripting language with a syntax like ABC but with the access to the Amoeba system calls. So
Van Rossum himself started designing a new simple scripting language that could overcome the
flaws of ABC.

1
Van Rossum started developing the new script in the late 1980s and finally introduced the first
version of that programming language in 1991. This initial release has module system of Modula-
3. Later on, this programming language was named ‘Python’.
Guido Van Rossum published the first version of Python code (version 0.9.0) at alt.sources in
February 1991. This release included already exception handling, functions, and the core data types
of list, dict, str and others. It was also object oriented and had a module system.

Python version 1.0 was released in January 1994. The major new features included in this release
were the functional programming tools lambda, map, filter and reduce, which Guido Van Rossum
never liked.
Six and a half years later in October 2000, Python 2.0 was introduced. This release included list
comprehensions, a full garbage collector and it was supporting unicode.
Python flourished for another 8 years in the versions 2.x before the next major release as Python
3.0 (also known as "Python 3000" and "Py3K") was released. Python 3 is not backwards
compatible with Python 2.x. The emphasis in Python 3 had been on the removal of duplicate
programming constructs and modules, thus fulfilling or coming close to fulfilling the 13th law of
the Zen of Python: "There should be one -- and preferably only one -- obvious way to do it."

1.3 Features
Python has some irresistible key features which need to be understood before getting your hands
dirty with python coding:

1.3.1: Very Easy-to-Learn


Python programming language gained its popularity just because of less usage of
keywords, simple structure and clearly defined syntax. People picked python because
the codes are easily readable and understandable. Due to such shift many online python
courses also made their way and people found an easier way to learn the language.

1.3.2: Ported to Other Platforms


Python is an open source language i.e. it can be ported to different platforms. Python
has no compatibility issues with other platforms unless all the system dependent
features are fixed. Like Perl, stock Python even offers a portable set of bindings to the
Tk toolkit that supports portable GUIs across Unix, MacOS, and Windows.

1.3.3: Object- Oriented Language

2
Great thing about Python is that it has support for both procedure-oriented
programming as well as object-oriented programming. The programs for procedure-
oriented languages are built around functions or procedures and can be reused. In
object-oriented languages, the program is built around objects which combine data and
functionality. An object-oriented language includes data and functionality in their
object. Unlikely many big languages like C++ or Java, Python comes with a very
powerful and simple way of using object-oriented programming.

1.3.4: Dynamic in Nature


Python owns this dynamic nature which makes the execution very easy. The modules
are compiled at import time with the interpretation of object messages done and
problem reported at the run time.
In C++, the changes done in the centrally used class header will lead to lengthy
recompilation of dependent modules. Again with Java, the changes to the public
interface of a class can invalidate a number of other modules. With every change,
recompilation is required in the best case or runtime errors in the worst case.

1.3.5: Extendable & Scalable


Python can be extended by adding low-level modules to its interpreter. The modules
only enable the programmers to add or modify their tools to be more efficient. Python
is also scalable because it provides a better structure and support for large programs
than shell scripting.
These are some of the best features of python, along with these it has a lot more
distinguished features to attract programmers. If you have still not started learning
python, then you are missing something very interesting. Besides this understanding
and learning python is very easy as compared to many other languages.

1.4 Libraries
Python's large standard library, commonly cited as one of its greatest strengths, provides tools
suited to many tasks. For Internet-facing applications, many standard formats and protocols such
as MIME and HTTP are supported. It includes modules for creating graphical user interfaces,
connecting to relational databases, generating pseudorandom numbers, arithmetic with arbitrary-
precision decimals, manipulating regular expressions, and unit testing.
Some parts of the standard library are covered by specifications (for example, the Web Server
Gateway Interface (WSGI) implementation wsgiref follows PEP 333), but most modules are not.
3
They are specified by their code, internal documentation, and test suites (if supplied). However,
because most of the standard library is cross-platform Python code, only a few modules need
altering or rewriting for variant implementations.
As of March 2018, the Python Package Index (PyPI), the official repository for third-party Python
software, contains over 130,000 packages with a wide range of functionality, including: Graphical
user interface
Web frameworks
 Multimedia
 Databases
 Networking
 Test frameworks
 Automation
 Web scraping
 Image Processing
 System administration
 Scientific computing
 Text processing

1.5 Web Frameworks


Most developers use frameworks to create code and develop applications. The framework provides
a defined structure to the developers so that they can focus on the core logic of the application
rather than on other elements. In order to start development with Python, you will require a
platform or framework to code. While choosing a framework, remember to consider the size and
complexity of your application or project.

Generally, there are two types of Python framework used while developing applications.

1.5.1 Full Stack Frameworks

The full-stack frameworks provide complete support to developers, including


necessary elements such as form validation, form generators, and template layouts.
Some of the common full-stack frameworks are:
1. Django: Django, developed by Django Software Foundation, is a full-
stack Python web framework. It is an open source and free-to-use
framework, released officially in July 2005. It helps developers to create
complex code and applications in an easier way, and requires much less
4
time compared to other frameworks. It follows the principle of DRY
(don’t repeat yourself) and a model-view-template architectural pattern.

2. Web2py: Web2py, developed by Massimo De Pierro, is a cross-


platform web application framework written in Python programming
language. It is an open source and free-to-use Python web framework,
released in September 2007. It enables users to create dynamic web
content in Python. The Web2py framework comes with a code editor,
debugger, and deployment tool with which you can develop and debug
code, as well as test and maintain applications. It incorporates a ticketing
system, which issues a ticket to the user whenever an error occurs. This
ticket helps the user to track the status of the error.

3. TurboGears: TurboGears, developed by KevinDangoor and Mark


Ramm, is a full-stack web application framework. It is a data-driven,
open source and free-to-use Python web framework. With the help of
components such as WebOb, SQLAlchemy, Genshi, and Repoze, you can
easily develop applications that require database connectivity much
faster as compared to other existing frameworks.

4. CubicWeb: CubicWeb, developed by Logilab, is an open source,


semantic, and free-to-use Python web framework. This framework is
based on the data model. You are required to define the data model in
order to get a functional application. It uses the cube in place of using
separate views and models. Multiple cubes are joined together to create
an instance with the help of some configuration files, a web server, and
a database.

5. Giotto: Giotto is a Python framework that is based on the MVC (Model


View Controller) pattern. It separates Model, View, and Controller
elements in order to ensure that the web designers, web developers, and
system administrators can perform their functions independently and
effectively.

5
1.5.2 Non-Full-Stack Frameworks

The non-full-stack frameworks do not provide additional functionalities and


features to the users. Developers need to add a lot of code and other things manually.
Some commonly used Python frameworks are:
1. Bottle: Bottle, developed by Marcel Hellkemp, is a microframework. It
is an easy-to-use lightweight framework generally used to build small
web applications. It creates a single source file of every project or
application. It has no other dependency than Python Standard Library.

2. CherryPy: CherryPy is an open source object-oriented Python


framework. Remi Delon is known as the founder of the CherryPy
project. The CherryPy framework is widely implemented by developers
to create Python web applications. It has its own multi-threaded web
server.You can create applications using CherryPy that will run on any
Python-supporting operating systems such as Windows, Linux/Unix,
and macOS.

3. Flask: Flask, developed by Armin Ronacher, is a powerful Python web


application framework. It is generally termed a microframework
because it does not have the following elements:

 Specific tools and libraries


 No database abstraction layer
 No form validation

4. Sanic: Sanic is an easy, open source, and simple Python


framework. This framework is similar to Flask in function but it is
much faster comparatively. It was specially designed for quick
HTTP responses with the help of asynchronous request handlers.

5. Tornado: Tornado, developed by Ben Darnell and Bret Taylor, is


a Python web application framework. Initially, it was developed for
a company named FriendFeed, which was later taken over by
Facebook in 2009. Tornado is an open source framework and is
generally known for its high performance.

6
2. Django

2.1 Introduction
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.

1. It’s very easy to switch database in Django framework.


2. It has built-in admin interface which makes easy to work with it.
3. Django is fully functional framework that requires nothing else.
4. It has thousands of additional packages available.
5. It is very scalable.

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

2.2 History
Django was design and developed by Lawrence journal world in 2003 and publicly released under
BSD license in July 2005. Currently, DSF (Django Software Foundation) maintains its development
and release cycle. Django was released on 21, July 2005. Its current stable version is 2.0.3 which was
released on 6 March, 2018.

Here’s an overview of when deprecated features will be dropped in Django going forward:

 1.8 - April 2015 (LTS): Dropped deprecation shims added in 1.6.

 1.9 - Dec. 2015: Drop deprecation shims added in 1.7.

7
 1.10 - Aug. 2016: Drop deprecation shims added in 1.8. This still allows running code that was
deprecation-warning free on 1.8; the shims dropped are for supporting older unsupported
versions.

 1.11 - April 2017 (LTS): No deprecation shims dropped. The 1.9 deprecation shims are needed
to help apps maintain compatibility back to 1.8 LTS.

 2.0 - Dec. 2017: Drop deprecation shims added in 1.9 and 1.10. Apps may drop support for
Django 1.8, 1.9, and 1.10 -- 1.8 support will end in April 2018, approximately 4 months after
the release of 2.0, and the other two versions are now unsupported.

 2.1 - Aug. 2018: Drop deprecation shims added in 1.11. This still allows running code that was
deprecation-warning free on 1.11; the shims dropped are for supporting older unsupported
versions.

 2.2 - April 2019 (LTS): No deprecation shims dropped. The 2.0 deprecation shims are needed
to help apps maintain compatibility back to 1.11 LTS.

Future versions: 3.0, 3.1, 3.2 (LTS), 4.0, etc.

2.3 Features

Django has some key features which need to be understood :

2.3.1 Complete
Django follows the "Batteries included" philosophy and provides almost everything developers
might want to do "out of the box". Because everything you need is part of the one "product", it
all works seamlessly together, follows consistent design principles, and has extensive and up-
to-date documentation.

2.3.2 Versatile
Django can be (and has been) used to build almost any type of website — from content
management systems and wikis, through to social networks and news sites. It can work with any
client-side framework, and can deliver content in almost any format (including HTML, RSS
feeds, JSON, XML, etc). The site you are currently reading is based on Django!
Internally, while it provides choices for almost any functionality you might want (e.g. several
popular databases, templating engines, etc.), it can also be extended to use other components if
needed.

2.3.3 Secure
8
Django helps developers avoid many common security mistakes by providing a framework that
has been engineered to "do the right things" to protect the website automatically. For example,
Django provides a secure way to manage user accounts and passwords, avoiding common
mistakes like putting session information in cookies where it is vulnerable (instead cookies just
contain a key, and the actual data is stored in the database) or directly storing passwords rather
than a password hash.
A password hash is a fixed-length value created by sending the password
through a cryptographic hash function. Django can check if an entered password is correct by
running it through the hash function and comparing the output to the stored hash value. However
due to the "one-way" nature of the function, even if a stored hash value is compromised it is
hard for an attacker to work out the original password.
Django enables protection against many vulnerabilities by default, including SQL injection,
cross-site scripting, cross-site request forgery and clickjacking (see Website security for more
details of such attacks).

2.3.4 Scalable
Django uses a component-based “shared-nothing” architecture (each part of the architecture is
independent of the others, and can hence be replaced or changed if needed). Having a clear
separation between the different parts means that it can scale for increased traffic by adding
hardware at any level: caching servers, database servers, or application servers. Some of the
busiest sites have successfully scaled Django to meet their demands (e.g. Instagram and Disqus,
to name just two).

2.3.5 Maintainable
Django code is written using design principles and patterns that encourage the creation of
maintainable and reusable code. In particular, it makes use of the Don't Repeat Yourself (DRY)
principle so there is no unnecessary duplication, reducing the amount of code. Django also
promotes the grouping of related functionality into reusable "applications" and, at a lower level,
groups related code into modules (along the lines of the Model View Controller
(MVC) pattern).

2.3.6 Portable
Django is written in Python, which runs on many platforms. That means that you are not tied to
any particular server platform, and can run your applications on many flavours of Linux,
Windows, and Mac OS X. Furthermore, Django is well-supported by many web hosting
providers, who often provide specific infrastructure and documentation for hosting Django sites.
9
3. Django Architecture and Code

3.1 Django Architecture


In a traditional data-driven website, a web application waits for HTTP requests from the web browser
(or other client). When a request is received the application works out what is needed based on the URL
and possibly information in POST data or GET data. Depending on what is required it may then read
or write information from a database or perform other tasks required to satisfy the request. The
application will then return a response to the web browser, often dynamically creating an HTML page
for the browser to display by inserting the retrieved data into placeholders in an HTML template.
Django web applications typically group the code that handles each of these steps into separate files:

 URLs: While it is possible to process requests from every single URL via a single function, it
is much more maintainable to write a separate view function to handle each resource. A URL
mapper is used to redirect HTTP requests to the appropriate view based on the request URL.

10
The URL mapper can also match particular patterns of strings or digits that appear in an URL,
and pass these to a view function as data.

 View: A view is a request handler function, which receives HTTP requests and returns HTTP
responses. Views access the data needed to satisfy requests via models, and delegate the
formatting of the response to templates.

 Models: Models are Python objects that define the structure of an application's data, and
provide mechanisms to manage (add, modify, delete) and query records in the database.

 Templates: A template is a text file defining the structure or layout of a file (such as an HTML
page), with placeholders used to represent actual content. A view can dynamically create an
HTML page using an HTML template, populating it with data from a model. A template can be
used to define the structure of any type of file; it doesn't have to be HTML!

3.2 Code Working


A URL mapper is typically stored in a file named urls.py. In the example below, the
mapper (urlpatterns) defines a list of mappings between routes (specific URL patterns) and
corresponding view functions. If an HTTP Request is received that has a URL matching a specified
pattern then the associated view function will be called and passed the request.

 Sending the request to the right view (urls.py)

urlpatterns = [

path('admin/', admin.site.urls),

path('book/<int:id>/', views.book_detail, name='book_detail'),

path('catalog/', include('catalog.urls')),

re_path(r'^([0-9]+)/$', views.best),

11
The urlpatterns object is a list of path() and/or re_path() functions (Python lists are defined using
square brackets, where items are separated by commas and may have an optional trailing comma. For
example: [item1, item2, item3,]).
The first argument to both methods is a route (pattern) that will be matched. The path() method uses
angle brackets to define parts of a URL that will be captured and passed through to the view function
as named arguments. The re_path() function uses a flexible pattern matching approach known as a
regular expression. We'll talk about these in a later article!
The second argument is another function that will be called when the pattern is matched. The
notation views.book_detail indicates that the function is called book_detail() and can be found in a
module called views (i.e. inside a file named views.py)

 Handling the request (views.py)

Views are the heart of the web application, receiving HTTP requests from web clients and returning
HTTP responses. In between, they marshall the other resources of the framework to access databases,
render templates, etc.

The example below shows a minimal view function index(), which could have been called by our URL
mapper in the previous section. Like all view functions it receives an HttpRequest object as a parameter
(request) and returns an HttpResponse object. In this case we don't do anything with the request, and
our response simply returns a hard-coded string. We'll show you a request that does something more
interesting in a later section.

# filename: views.py (Django view functions)

from django.http import HttpResponse

def index(request):

# Get an HttpRequest - the request parameter

# perform operations using information from the request.

# Return HttpResponse

return HttpResponse('Hello from Django!')

Views are usually stored in a file called views.py.

12
 Defining data models (models.py)
Django web applications manage and query data through Python objects referred to as models. Models
define the structure of stored data, including the field types and possibly also their maximum size,
default values, selection list options, help text for documentation, label text for forms, etc. The definition
of the model is independent of the underlying database — you can choose one of several as part of your
project settings. Once you've chosen what database you want to use, you don't need to talk to it directly
at all — you just write your model structure and other code, and Django handles all the dirty work of
communicating with the database for you.
The code snippet below shows a very simple Django model for a Team object. The Team class
is derived from the django class models.Model. It defines the team name and team level as character
fields and specifies a maximum number of characters to be stored for each record. The team_level can
be one of several values, so we define it as a choice field and provide a mapping between choices to be
displayed and data to be stored, along with a default value.

# filename: models.py

from django.db import models

class Team(models.Model):

team_name = models.CharField(max_length=40)

TEAM_LEVELS = (

('U09', 'Under 09s'),

('U10', 'Under 10s'),

('U11', 'Under 11s'),

... #list other team levels

team_level = models.CharField(max_length=3, choices=TEAM_LEVELS, default='U11')

 Querying data (views.py)


The Django model provides a simple query API for searching the database. This can match against a
number of fields at a time using different criteria (e.g. exact, case-insensitive, greater than, etc.), and

13
can support complex statements (for example, you can specify a search on U11 teams that have a team
name that starts with "Fr" or ends with "al").
The code snippet shows a view function (resource handler) for displaying all of our U09 teams. The
line in bold shows how we can use the model query API to filter for all records where
the team_level field has exactly the text 'U09' (note how this criteria is passed to the filter() function as
an argument with the field name and match type separated by a double underscore: team_level__exact).

## filename: views.py

from django.shortcuts import render

from .models import Team

def index(request):

list_teams = Team.objects.filter(team_level__exact="U09")

context = {'youngest_teams': list_teams}

return render(request, '/best/index.html', context)

This function uses the render() function to create the HttpResponse that is sent back to the browser.
This function is a shortcut; it creates an HTML file by combining a specified HTML template and some
data to insert in the template (provided in the variable named "context"). In the next section we show
how the template has the data inserted in it to create the HTML.

 Rendering data (HTML templates)


Template systems allow you to specify the structure of an output document, using placeholders for data
that will be filled in when a page is generated. Templates are often used to create HTML, but can also
create other types of document. Django supports both its native templating system and another popular
Python library called Jinja2 out of the box (it can also be made to support other systems if needed).

The code snippet shows what the HTML template called by the render() function in the previous section
might look like. This template has been written under the assumption that it will have access to a list
variable called youngest_teams when it is rendered (contained in the context variable inside
the render() function above). Inside the HTML skeleton we have an expression that first checks if

14
the youngest_teams variable exists, and then iterates it in a for loop. On each iteration the template
displays each team's team_name value in an <li> element.

## filename: best/templates/best/index.html

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="utf-8">

<title>Home page</title>

</head>

<body>

{% if youngest_teams %}

<ul>

{% for team in youngest_teams %}

<li>{{ team.team_name }}</li>

{% endfor %}

</ul>

{% else %}

<p>No teams are available.</p>

{% endif %}

</body>

</html>

3.3 Some Other Functionalities


The preceding sections show the main features that you'll use in almost every web application: URL
mapping, views, models and templates. Just a few of the other things provided by Django include:

15
 Forms: HTML Forms are used to collect user data for processing on the server. Django simplifies form
creation, validation, and processing.
 User authentication and permissions: Django includes a robust user authentication and permission
system that has been built with security in mind.
 Caching: Creating content dynamically is much more computationally intensive (and slow) than
serving static content. Django provides flexible caching so that you can store all or part of a rendered
page so that it doesn't get re-rendered except when necessary.
 Administration site: The Django administration site is included by default when you create an app
using the basic skeleton. It makes it trivially easy to provide an admin page for site administrators to
create, edit, and view any data models in your site.
 Serialising data: Django makes it easy to serialise and serve your data as XML or JSON. This can be
useful when creating a web service (a website that purely serves data to be consumed by other
applications or sites, and doesn't display anything itself), or when creating a website in which the client-
side code handles all the rendering of data.

4. My Project

4.1 Introduction

To develop the Online Hostel and PG searching website, the work is started by gather information
about the topic. The technology such as software and hardware needed to develop the study are
decided. To gather requirements of this study, discussion is held within supervisor and hostels and
PG owners.
After studying and analyzing the flow of the current system of hostel and PGs, the system
would like the following:
The system proves to be fast accurate convenient, efficient and reliable for the process of reservation.
The online searching system suitable for the hotel; the system could save time, effort in filling and
monitoring.
Hostel and PGs searching system plays a great role and has a potential effect on day to day
performance measures. Due to the rapid change of technology the use of such system has become a
necessity to any given high learning institution for better performance and be used with quite a large
number of users at the same time but it can save time, resources and creates awareness of the evolving
technology.

16
4.2 Goals
The goal of the current system is to develop a Online Hostel and PG Searching website to replace the
manual searching. The purpose of the document is to describe requirements for the Online Hostel and
PG Searching Software that will serve as a foundation for the final product. This document uses written
descriptions as well as various types of modeling diagrams to illustrate the high level structure of the
application. Although some of these diagrams may seem to convey similar information they typically
do so from an alternate perspective. This gives different stakeholders a view of the requirements that
is better suited to their area responsibility.
A web based solution will be delivered so that users the system with their favorite browser. By
designing around a standardized language like PYTHON( Django web framework) the application will
run on the most popular computer platforms connected to the internet will allow peoples and owners
to more easily share information.
Many typical things involved in finding a hostel or a PG will be automated through software
to improve the operational workflow within a facility, for instance Checking the Availability of the
room in particular PG or Hostel. In addition, tasks like Post PG and Hostel details and Drop Messages
will be available within the program to minimize the time that waste in searching on area to area by
walking or by calling.

4.3 Usage Scenario


4.3.1 User Profiles

The following definitions describe the actors in the system.

Admin An admin has the responsibility to look the customer which were added and
also he can access the system he can remove any user which is not genuine
and check the PG or Hostel details request. He can remove the PG or Hostel
according to the requirements.

Person Here the customer can only view the PG and hostel according to the area if a
customer want to add their PG and hostel he can post details of their PG and
hostel also.

System The system refers to the computer hardware and software that controls all
application. Its accepts user input ,display user output, and web server thru
internet.

17
4.3.2 Use Case

The following is how the person use the website:

1. Log onto system.

2. Display available PG and Hostels.

3. Get the PG and Hostel details Click on the images.

4. Post the details of their PG and Hostel.

4.3.3 Use-Case Diagram

Get PG &
Hostel
details

Send
Messages
to admin

Post Hostel
Person and PG
Details

Use case For Person Who Registered

18
Update
Hostel &
PG

Remove
Users
Admin

Use case for Admin

19
5. Website Overview

5.1 Homepage For Users


You never get a second chance to make a first impression -- that’s why your homepage is undoubtedly one of
the most important web pages on your website.
For any given company, the homepage is its virtual front door. If a new visitor doesn't like what they see, their
knee-jerk reaction is to hit the "back" button.
That's right -- unfortunately, a lot of people still judge a book by its cover.
What makes a website's homepage design brilliant instead of bland? It takes more than looks alone -- it also
has to work well. That's why the most brilliant homepages on this list don't just score high in beauty, but also
in brains and creativity.

20
5.2 Images Section of the Website
In the beginning, the Web was just text, and it was really quite boring. Fortunately, it wasn't too long before
the ability to embed images (and other more interesting types of content) inside web pages was added.

Here are the images of the room


which are available in the
website.
You only see the images of the
PG and Hostel until you not
logged in
When you click on the image if
you are not logged in website
redirect to login page so you have
to login.

21
5.3 Services Section of Webpage
Trust is a bigger part of selling services. A faulty product can be returned, and flaws are relatively
objective. But with services, customers may worry about what recourse they will have if they’re
unhappy, even if you offer excellent customer service guarantees.
It’s likely that the services page isn’t the first thing potential customers see on your website. Perhaps
they came in through blog posts, or Google searches brought them to your home page. Either way,
they want to know more about you—but that doesn’t necessarily mean they already have a good idea
of what you do. Sure, some visitors have already read your home page and FAQs, but others came in
via social media or a blog post and haven’t read anything else. They chose to click on the services
page because they want to find out more.
Before asking people to dig in to the details of each of your services, give them a top-level view of
what you do and the unique value you offer . This opens the door for further conversation and
establishes the context through which they’ll interpret the rest of the information they read.

22
5.4 Contact Section of the Website
A contact page is a standard web page on a website used to allow the visitor to contact the website owner or
people who are responsible for the maintenance of the site. The page often contains one or more of the
following items:
 a mail to link to an e-mail address.
 a description of personalia like a (organization) name, address, zip code, residential area, with
sometimes a map indicating a certain physical location and a description or visualization of how to get
there;
 a set of visual icons or textual links to social networking services;
 a contact form with entries where the visitor can fill in their name, subject and message and send or reset
it.

Here you can contact to the


website owner by sending
message here you have to
fill you name and email
address at last you have to
type a message and click on
send message

23
5.5 Sign up Page of the Website
A registration form is a list of fields that a user will input data into and submit to a company or individual.
There are many reasons why you would want a person to fill out a registration form. Companies use
registration forms to sign up customers for subscriptions, services, or other programs or plans.

If you are register to website so you have


to register first . There is Signup icon on
the homepage when you click on the icon
you get a dialogue box as you seen in the
image .
There were fields which you have to
filled correctly and click on the Signup
button and you were registered now go to
login page for login

24
Here is the code of signup page functioning how a signup page function

25
5.6 OTP verification After Signup
After Click on the Signup
When you click on the signup this would redirect to the OTP verification page where your mail get verified.

You have to type the OTP here which


were send to your email filled in the email
field while registering
The OTP should be matched with the OTP
in your email

26
Codes for OTP generation and checking

Here is the code for


the generation of the
OTP
Here the 4-digit OTP
generated and stored
in the session for
future use in
checking the OTP

This code use to


Check the OTP by
comparing the OTP
generated at the time
of registration and
the user type for the
verification of the
email

27
5.7 Login Page of Website
Logins are used by websites, computer applications, and mobile apps. They are a security measure designed
to prevent unauthorized access to confidential data. When a login fails (i.e, the username and password
combination does not match a user account), the user is disallowed access.

After Signup you have to Signin to the


page
You have to put your email and
password correctly if you put it correctly
then you have to redirect towards to the
next page where you can see PG and
Hostel according to the area you like on
just a click

28
Here is the code for the login functionality

The username and the password registered by the


user were checked in the database if there is email
and the password in database the user redirected to
next page if not registered then login is
unsuccessful

29
5.8 Forgot password

When you click on


the forgot password
the page open where
you have to enter the
email address and an
OTP were send to
email

Here you have


to enter the new
password in the
password field
and same
password in the
confirm
password if the
password
matched your
password
change now

30
Codes for Forgot Password

Here the change password function work


from
Two passwords were match one in
password field and other one in confirm
password field if to were matched then the
homepage open

31
Here is the code for the
generation of the OTP
Here the 4-digit OTP
generated and stored
in the session for
future use in checking
the OTP

This code use to Check


the OTP by comparing
the OTP generated at
the time of registration
and the user type for
the verification of the
email

32
5.9 Homepage After Login

When a person click on this it When you here there is page open
redirects to a page where you get where you post there your hostel
the Hostel and PG according to and PG details. By this other
the locality you want and it peoples view your Hostel and PG.
shows PG and hostels for boys
There is also a message box for
and girls
sending message

Log out
By this you were logged
out and redirect to
homepage

33
5.10 GET PG

When you click on the PG according to


your choice of the area it will redirected
towards the PG available in the area
you selected

If there is no PG available in the area


there is message shown at the top that
there is no PG available the area

34
After click on the PG according to Choice of the Area

When you click on the PG


of the particular area the
data stored in database
according to area where
displayed on the screen if
there is no entry in the
database than there is no PG
available were displayed on
the screen

35
5.11 POST PG Details

There were different fields like Area of the


PG, Images of the PG, Contact Details etc. In
order to display your PG on the website you
have fill details and click on the submit
details

36
Code For Post PG details

Here is the code how to details of


the PG Get from the HTML page
and stored in the database and after
this the stored details were
displayed on the website when a
user logged in to view PG and
Hostel

37
Forms use in the website
Codes used to make forms

In this piece of code there is collection of


forms named as

1. Log in Form
2. Sign up Form
3. OTP Form
4. Check OTP Form
5. Change Password Form

These are all store in file named as form.py

38
There are more forms which are:

1. Room Post Forms


2. Contact Forms

39
Database System
There is database name as Sqlite3 which I used in my project
Codes to make database tables are:

There were two tables which I created in the database

1. User
2. Postmodel

In User table all the details of the user were store

In Postmodel table all the information about the PG and


Hostel were stored

From these table the information were used to display or


perform other on the website

These tables are easily access by the admin

40
5.12 Admin Login Screen

This is the admin login page


to login the administrator. if
username and password are
matched from the admin
table , login successfully
otherwise login unsuccessful.

5.1.1 Creating an admin user


First we’ll need to create a user who can login to the admin site. Run the following command:
$ python manage.py createsuperuser
Enter your desired username and press enter.
Username: admin
You will then be prompted for your desired email address:
Email address: [email protected]
The final step is to enter your password. You will be asked to enter your password twice, the second
time as a confirmation of the first.
Password: **********
Password (again): *********
Superuser created successfully.

41
5.13 Admin Page After Login

Admin have control over all the things


which are present in the website
Here the admin can add the PG details or
he can remove the PG from the database
Admin can add users and also remove the
user from the database

42
5.14 User Details

Admin get all the details of the


registered user in the website .

Admin can see all the user.

By this page Admin can remove the user


according to his choice .

Admin can change the details of the user


also.

43
5.15 PG Details in Admin Panel

Here the Admin can change the PG details


which is shown in the website

Admin can also delete the PG information


according to his choice

44
45

You might also like