0% found this document useful (0 votes)
44 views

Online Note Share Report Shiv Chaudhary

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Online Note Share Report Shiv Chaudhary

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

lOMoARcPSD|38596729

Online Note Share Report (Shiv Chaudhary)

CSIT (Tribhuvan Vishwavidalaya)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Bhagyavant Rajapur ([email protected])
lOMoARcPSD|38596729

ONLINE NOTE SHARING

PROJECT REPORT
OF MAJOR PROJECT

Submitted by

Shiv Kumar Chaudhary Kurmi


82BTCS810729

Under the guidance of

Mr. Bhavendra Kumar Sinha


In partial fulfillment for the award of the degree
Of
Bachelor of Technology (Computer Science)
In

BRANCH OF STUDY
Of
COMPUTER SCIENCE AND ENGINEERING
KALINGA UNIVERSITY
Village Kotni, Near Mantralaya Naya Raipur (C.G.).
Session July: 2021-2021

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

DECLARATION

This is to certify that this training report entitled “ONLINE NOTE SHARING” which is submitted by me
in partial fulfillment of the requirement for the completion of Bachelor of Technology (Computer
Science) to Computer Science and Engineering, Kalinga University, Atalnagar (C.G.), comprises my
original work and due acknowledgement has been made in the text to all other material and resources used.

Signature…………………………... Name of the Student:


SHIV KUMAR CHAUDHARY KURMI CT IFICATE
OF COMPLETION

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

CERTIFICATE OF COMPLETION

This is to certify that SHIV KUMAR CHAUDHARY KURMI student of B. Tech.

(CS) has completed the Training Report titled “COMPUTER APPLICATIONS”.


The training report has been written according to the guidelines given by the Computer Science and
Engineering Department, Kalinga University, Raipur (C.G.

Signature of the Head of Institution : ……………………… Date :


Name of the Head of Institution : Place:

CERTIFICATE OF EVALUATION

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

This is to certify that the undersigned have assessed and evaluated the Report entitled “ONLINE NOTE
SHARING” submitted by the SHIV KUMAR CHAUDHARY KURMI. The Training Report has been
accepted for the partial fulfillment of B. Tech. (CS) program.

……………………………. ………………..................... . .
Signature of the External Examiner Signature of the Internal Examiner

PREFACE

The main objective of any computer science student is to get as much of practical knowledge as possible.
Being able to have a practical knowledge by developing a project is a lifetime experience. As practical

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

knowledge is as important as theoretical knowledge. I am thankful to our respected Computer Science


Department for giving me this opportunity to work on this project.

Through the development of the project I had a great experience of various strategies that can be applied in
development of project. This project is the stepping stone for our carrier.

I am pleased to present this project. Proper care has been taken while organizing the project so that it is to
comprehend. Also, various software engineering concepts have been implemented.

ACKNOWLEDGEMENT

I would like to express my special thanks of gratitude to my teacher of Computer Science Department as
well as my college Kalinga University for giving me golden opportunity to do this wonderful project on the

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

topic “ONLINE NOTE SHARE”, which also helped me in doing a lot of research and I came to know so
many new things I am really thankful to them.

Secondly, I would also like to thank my parents and friends who helped me a lot in finalizing this project
within the limited time frame.

Last but not the least, I would hearty thank the almighty for giving me strength to complete my report on
time.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

INDEX

S. No. Topics Page. No.

1. Introduction

2. Objectives and scopes

3. Need of ONLINE NOTE SHARING

4. System specification

5. Tools, platform and language used

6. Screenshot

7. Reference

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

INTRODUCTION

The “Online Note Sharing” is web based project designed python programming language. This is website
designed to share the notes over the internet between the different user. This is designed with the help of
Django framework as backend and html, css, javascript and bootstrap as backend. I have used SQLite
database to store the data . This is very beneficial for those universities, institute, collage, etc who share
their notes between the students. On other hand students are also able to share their notes between their
friends.
Most of the colleges, universities, institute, etc. are uses whatapp or any other social media platforms to
share the notes between their students but what for those students who do not use any social media platform
, they won’t get any notes. So to solve this problem this website play important role.
Today in this busy world everyone want to make things easy. Thus there is great challenge of sharing the
notes between the students. The time like this pandemics all the things are shifted towards online so there
needs of such platform where the students as well as teacher can share their notes, here online note sharing
projects comes into the picture. This provide easy and safe way of sharing the notes.

Most of the colleges, universities, etc have problems while sharing the notes or any other files between their
students, partner or any needy people. Sharing the notes or any files using social media is not too safe and
effective that’s why this websites play important role while sharing the notes between the people. Here
students can store their notes for future uses and able to download whenever they want to.

OBJECTIVES AND SCOPES

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

• Online Note Sharing Application deals with borrowing and transferring the notes over the internet.
• It is a WEB-based system especially designed for students of any branch of any college , school , and
universities.
• This system is being produced for students interested in borrowing and giving their own notes for the
free of cost.
• This Project aims for providing the digital platform for the user where they can request notes as per
required and another user of this same platform can supply that notes to the requesting user.
• The general objective of this application is to provide the platform where students can contact the
owner of notes efficiently.
• To provide the platform for the user to connect for the borrowing and donating the notes.
• To ensure that the note circulation is occurred within the user.

Online Note Sharing project is web based application which is developed in python by using Django
framework and SQLite database. It is designed for easy note sharing, user can upload their notes by
creating his/her account. He /she can also able to download the notes uploaded by him/her or others.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

NEED OF ONLINE NOTE SHARING

Today in this busy world everyone want to make things easy. Thus there is great challenge of sharing the
notes between the students. The time like this pandemics all the things are shifted towards online so there
needs of such platform where the students as well as teacher can share their notes, here online note sharing
projects comes into the picture. This provide easy and safe way of sharing the notes.

Most of the colleges, universities, etc have problems while sharing the notes or any other files between their
students, partner or any needy people. Sharing the notes or any files using social media is not too safe and
effective that’s why this websites play important role while sharing the notes between the people. Here
students can store their notes for future uses and able to download whenever they want to.

SYSTEM SPECIFICATIONS

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

 HARDWARE
o RAM: 4GB

 SOFTWARE
o Any Operating System

o Front End: Python

o Back End: Html, CSS, JavaScript and Bootstrap

o Database: SQLite

 Framework
o Django

 STORAGE
o At least 2 GB for software installation. o Data storage depending upon
organizational setup.
 PROCESSOR
o Intel Pentium III, 1GHZ or above.

Methodology/Planning:
 First User have to create his/her account.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

 As soon as account is created he/she is able to login.


 After login user will move to the user home page.
 In user home page user can upload notes, views notes and download the notes.
 User can also able to edit their profile, can change their password.
 All activities of user is control by admin.
 Admin has a right to delete the user, accept or reject the notes uploaded by the user.

TOOLS, PLATFORM AND LANGUAGE USED

FRONT END

Frontend is designed by using following technologies:

 HTML

 CSS
 Bootstrap 4
 JavaScript

HTML
The Hypertext Markup Language, or HTML 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 (CSS)
and scripting languages such as JavaScript.
Web browsers receive HTML documents from a web server or from local storage and render the documents
into multimedia web pages. HTML describes the structure of a web page semantically and originally
included cues for the appearance of the document.
HTML elements are the building blocks of HTML pages. With HTML constructs, images and other objects
such as interactive forms may be embedded into the rendered page. HTML provides a means to
create structured documents by denoting structural semantics for text such as headings, paragraphs,
lists, links, quotes and other items. HTML elements are delineated by tags, written using angle brackets.
Tags such as <img /> and <input /> directly introduce content into the page. Other tags such
as <p> surround and provide information about document text and may include other tags as sub-elements.
Browsers do not display the HTML tags, but use them to interpret the content of the page.
HTML can embed programs written in a scripting language such as JavaScript, which affects the behavior
and content of web pages. Inclusion of CSS defines the look and layout of content. The World Wide Web
Consortium (W3C), former maintainer of the HTML and current maintainer of the CSS standards, has
encouraged the use of CSS over explicit presentational HTML since 1997.

CSS

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document
written in a markup language such as HTML. CSS is a cornerstone technology of the World Wide Web,
alongside HTML and JavaScript.
CSS is designed to enable the separation of presentation and content, including layout, colors,
and fonts. This separation can improve content accessibility, provide more flexibility and control in the
specification of presentation characteristics, enable multiple web pages to share formatting by specifying the
relevant CSS in a separate .css file which reduces complexity and repetition in the structural content as well
as enabling the .css file to be cached to improve the page load speed between the pages that share the file
and its formatting.
Separation of formatting and content also makes it feasible to present the same markup page in different
styles for different rendering methods, such as on-screen, in print, by voice (via speech-based browser
or screen reader), and on Braille-based tactile devices. CSS also has rules for alternate formatting if the
content is accessed on a mobile device.
The name cascading comes from the specified priority scheme to determine which style rule applies if more
than one rule matches a particular element. This cascading priority scheme is predictable.
The CSS specifications are maintained by the World Wide Web Consortium (W3C). Internet media type
(MIME type) text/css is registered for use with CSS by RFC 2318 (March 1998). The W3C operates a
free CSS validation service for CSS documents.
In addition to HTML, other markup languages support the use of CSS including XHTML, plain XML, SVG,
and XUL.

Bootstrap
Bootstrap is a free and open-source CSS framework directed at responsive, mobile-first front-end
web development. It contains CSS- and (optionally) JavaScript-based design templates
for typography, forms, buttons, navigation, and other interface components.
Bootstrap 4
Mark Otto announced Bootstrap 4 on October 29, 2014. The first alpha version of Bootstrap 4 was released
on August 19, 2015. The first beta version was released on 10 August 2017. Mark suspended work on
Bootstrap 3 on September 6, 2016, to free up time to work on Bootstrap 4. Bootstrap 4 was finalized on
January 18, 2018.
Significant changes include:

 Major rewrite of the code


 Replacing Less with Sass
 Addition of Reboot , a collection of element-specific CSS changes in a single file, based
on Normalize
 Dropping support for IE8, IE9, and iOS 6
 CSS Flexible Box support
 Adding navigation customization options
 Adding responsive spacing and sizing utilities
 Switching from the pixels unit in CSS to root ems
 Increasing global font size from 14px to 16px for enhanced readability
 Dropping the panel , thumbnail , pager , and well components
 Dropping the Glyphicons icon font
 Huge number of utility classes
 Improved form styling, buttons, drop-down menus, media objects and image classes

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Bootstrap 4 supports the latest versions of the Google Chrome, Firefox, Internet Explorer, Opera,
and Safari (except on Windows). It additionally supports back to IE10 and the latest Firefox Extended
Support Release (ESR).

JavaScript
JavaScript often abbreviated as JS, is a programming language that conforms to
the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm. It
has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions.
Alongside HTML and CSS, JavaScript is one of the core technologies of the World Wide Web. Over 97%
of websites use it client-side for web page behavior, often incorporating third-party libraries. All major web
browsers have a dedicated JavaScript engine to execute the code on the user's device.
As a multi-paradigm language, JavaScript supports event-driven, functional, and imperative programming
styles. It has application programming interfaces (APIs) for working with text, dates, regular expressions,
standard data structures, and the Document Object Model (DOM).
The ECMAScript standard does not include any input/output (I/O), such as networking, storage,
or graphics facilities. In practice, the web browser or other runtime system provides JavaScript APIs for I/O.
JavaScript engines were originally used only in web browsers, but they are now core components
of other software systems, most notably servers and a variety of applications.

BACK END

Django framework is used to design this website. Python is use as backend programming languages. These
are described below.
Python
Python is an interpreted high-level general-purpose programming language. Python's design philosophy
emphasizes code readability with its notable use of significant indentation. Its language constructs as well as
its object-oriented approach aim to help programmers write clear, logical code for small and large-scale
projects.
Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms,
including structured (particularly, procedural), object-oriented and functional programming. Python is often
described as a "batteries included" language due to its comprehensive standard library.
Guido van Rossum began working on Python in the late 1980s, as a successor to the ABC programming
language, and first released it in 1991 as Python 0.9.0. Python 2.0 was released in 2000 and introduced new
features, such as list comprehensions and a garbage collection system using reference counting and was
discontinued with version 2.7.18 in 2020.[33] Python 3.0 was released in 2008 and was a major revision of the
language that is not completely backward-compatible and much Python 2 code does not run unmodified on
Python 3.
Python consistently ranks as one of the most popular programming languages

Django (Framework)
Django (/ sometimes stylized as django) is a Python-based free and open-source web framework that
follows the model-template-views (MTV) architectural pattern.[9][10] It is maintained by the Django Software
Foundation (DSF), an American independent organization established as a 501(c)(3) non-profit.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Django's primary goal is to ease the creation of complex, database-driven websites. The framework
emphasizes reusability and "pluggability" of components, less code, low coupling, rapid development, and
the principle of don't repeat yourself.[11] Python is used throughout, even for settings, files, and data models.
Django also provides an optional administrative create, read, update and delete interface that is generated
dynamically through introspection and configured via admin models.
Components

Screenshot of the Django admin interface for modifying a user account.


Despite having its own nomenclature, such as naming the callable objects generating the HTTP responses
"views",[9] the core Django framework can be seen as an MVC architecture.[10] It consists of an object-
relational mapper (ORM) that mediates between data models (defined as Python classes) and a relational
database ("Model"), a system for processing HTTP requests with a web templating system ("View"), and
a regular-expression-based URL dispatcher ("Controller").
Also included in the core framework are:

 a lightweight and standalone web server for development and testing


 a form serialization and validation system that can translate between HTML forms and values
suitable for storage in the database
 a template system that utilizes the concept of inheritance borrowed from object-oriented
programming
 a caching framework that can use any of several cache methods
 support for middleware classes that can intervene at various stages of request processing and carry
out custom functions
 an internal dispatcher system that allows components of an application to communicate events to
each other via pre-defined signals

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

 an internationalization system, including translations of Django's own components into a variety of


languages
 a serialization system that can produce and read XML and/or JSON representations of Django model
instances
 a system for extending the capabilities of the template engine
 an interface to Python's built-in unit test framework
Bundled applications
The main Django distribution also bundles a number of applications in its "contrib" package, including:

 an extensible authentication system


 the dynamic administrative interface
 tools for generating RSS and Atom syndication feeds
 a "Sites" framework that allows one Django installation to run multiple websites, each with their own
content and applications
 tools for generating Google Sitemaps
 built-in mitigation for cross-site request forgery, cross-site scripting, SQL injection, password
cracking and other typical web attacks, most of them turned on by default[22][23]
 a framework for creating GIS applications

SOME IMPORTANT MODULES USED IN DJANGO

Model.py:

A model is the single, definitive source of information about your data. It contains the essential fields and
behaviors of the data you’re storing. Generally, each model maps to a single database table.

The basics:
Each model is a Python class that subclasses django.db.models.Model.
Each attribute of the model represents a database field.
With all of this, Django gives you an automatically-generated database-access API; see Making queries.
Quick example¶
This example model defines a Person, which has a first_name and last_name:
from django.db import models

class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
first_name and last_name are fields of the model. Each field is specified as a class attribute, and each
attribute maps to a database column.
The above Person model would create a database table like this:
CREATE TABLE myapp_person (

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

"id" serial NOT NULL PRIMARY KEY,


"first_name" varchar(30) NOT NULL,
"last_name" varchar(30) NOT NULL
);
Some technical notes:
The name of the table, myapp_person, is automatically derived from some model metadata but can be
overridden. See Table names for more details.
An id field is added automatically, but this behavior can be overridden. See Automatic primary key fields.
The CREATE TABLE SQL in this example is formatted using PostgreSQL syntax, but it’s worth noting
Django uses SQL tailored to the database backend specified in your settings file.

Using models¶
Once you have defined your models, you need to tell Django you’re going to use those models. Do this by
editing your settings file and changing the INSTALLED_APPS setting to add the name of the module that
contains your models.py.
For example, if the models for your application live in the module myapp.models (the package structure
that is created for an application by the manage.py startapp script), INSTALLED_APPS should read, in
part:
INSTALLED_APPS = [
#...
'myapp',
#...
]
When you add new apps to INSTALLED_APPS, be sure to run manage.py migrate, optionally making
migrations for them first with manage.py makemigrations.

View.py:
A view function, or view for short, is a Python function that takes a Web request and returns a Web
response. This response can be the HTML contents of a Web page, or a redirect, or a 404 error, or an XML
document, or an image . . . or anything, really. The view itself contains whatever arbitrary logic is necessary
to return that response. This code can live anywhere you want, as long as it’s on your Python path. There’s
no other requirement–no “magic,” so to speak. For the sake of putting the code somewhere, the convention
is to put views in a file called views.py, placed in your project or application directory.
A simple view¶
Here’s a view that returns the current date and time, as an HTML document:
from django.http import HttpResponse

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

import datetime

def current_datetime(request):
now = datetime.datetime.now()
html = "<html><body>It is now %s.</body></html>" % now
return HttpResponse(html)
Let’s step through this code one line at a time:
First, we import the class HttpResponse from the django.http module, along with
Python’s datetime library.
Next, we define a function called current_datetime. This is the view function. Each view function takes
an HttpRequest object as its first parameter, which is typically named request.
Note that the name of the view function doesn’t matter; it doesn’t have to be named in a certain way in
order for Django to recognize it. We’re calling it current_datetime here, because that name clearly
indicates what it does.
The view returns an HttpResponse object that contains the generated response. Each view function is
responsible for returning an HttpResponse object. (There are exceptions, but we’ll get to those later.)

Urls.py:
Django has his own way for URL mapping and it's done by editing your project url.py
file (myproject/url.py). The url.py file looks like −
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
#Examples
#url(r'^$', 'myproject.view.home', name = 'home'),
#url(r'^blog/', include('blog.urls')),

url(r'^admin', include(admin.site.urls)),
)
When a user makes a request for a page on your web app, Django controller takes over to look for the
corresponding view via the url.py file, and then return the HTML response or a 404 not found error, if not
found. In url.py, the most important thing is the "urlpatterns" tuple. It’s where you define the mapping
between URLs and views. A mapping is a tuple in URL patterns like −

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

from django.conf.urls import patterns, include, url


from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
#Examples
#url(r'^$', 'myproject.view.home', name = 'home'),
#url(r'^blog/', include('blog.urls')),

url(r'^admin', include(admin.site.urls)),
url(r'^hello/', 'myapp.views.hello', name = 'hello'),
)
The marked line maps the URL "/home" to the hello view created in myapp/view.py file. As you can see
above a mapping is composed of three elements −
The pattern − A regexp matching the URL you want to be resolved and map. Everything that can work
with the python 're' module is eligible for the pattern (useful when you want to pass parameters via url).
The python path to the view − Same as when you are importing a module.
The name − In order to perform URL reversing, you’ll need to use named URL patterns as done in the
examples above. Once done, just start the server to access your view via :http://127.0.0.1/hello

Organizing Your URLs


So far, we have created the URLs in “myprojects/url.py” file, however as stated earlier about Django and
creating an app, the best point was to be able to reuse applications in different projects. You can easily see
what the problem is, if you are saving all your URLs in the “projecturl.py” file. So best practice is to create
an “url.py” per application and to include it in our main projects url.py file (we included admin URLs for
admin interface before).

How is it Done?
We need to create an url.py file in myapp using the following code −

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

from django.conf.urls import patterns, include, url

urlpatterns = patterns('', url(r'^hello/', 'myapp.views.hello', name = 'hello'),)


Then myproject/url.py will change to the following −
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
#Examples
#url(r'^$', 'myproject.view.home', name = 'home'),
#url(r'^blog/', include('blog.urls')),

url(r'^admin', include(admin.site.urls)),
url(r'^myapp/', include('myapp.urls')),
)
We have included all URLs from myapp application. The home.html that was accessed through “/hello” is
now “/myapp/hello” which is a better and more understandable structure for the web app.

Now let's imagine we have another view in myapp “morning” and we want to map it in myapp/url.py, we
will then change our myapp/url.py to −
from django.conf.urls import patterns, include, url

urlpatterns = patterns('',
url(r'^hello/', 'myapp.views.hello', name = 'hello'),
url(r'^morning/', 'myapp.views.morning', name = 'morning'),

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Page Redirection:
Page redirection is needed for many reasons in web application. You might want to redirect a user to
another page when a specific action occurs, or basically in case of error. For example, when a user logs in
to your website, he is often redirected either to the main home page or to his personal dashboard. In
Django, redirection is accomplished using the 'redirect' method.
The 'redirect' method takes as argument: The URL you want to be redirected to as string A view's name.
The myapp/views looks like the following so far −
def hello(request):
today = datetime.datetime.now().date()
daysOfWeek = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
return render(request, "hello.html", {"today" : today, "days_of_week" : daysOfWeek})

def viewArticle(request, articleId):


""" A view that display an article based on his ID"""
text = "Displaying article Number : %s" %articleId
return HttpResponse(text)

def viewArticles(request, year, month):


text = "Displaying articles of : %s/%s"%(year, month)
return HttpResponse(text)
Let's change the hello view to redirect to djangoproject.com and our viewArticle to redirect to our internal
'/myapp/articles'. To do so the myapp/view.py will change to −
from django.shortcuts import render, redirect
from django.http import HttpResponse
import datetime

# Create your views here.


def hello(request):
today = datetime.datetime.now().date()
daysOfWeek = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
return redirect("https://www.djangoproject.com")

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

def viewArticle(request, articleId):


""" A view that display an article based on his ID"""
text = "Displaying article Number : %s" %articleId
return redirect(viewArticles, year = "2045", month = "02")

def viewArticles(request, year, month):


text = "Displaying articles of : %s/%s"%(year, month)
return HttpResponse(text)
In the above example, first we imported redirect from django.shortcuts and for redirection to the Django
official website we just pass the full URL to the 'redirect' method as string, and for the second example (the
viewArticle view) the 'redirect' method takes the view name and his parameters as arguments.

Template System:
Django makes it possible to separate python and HTML, the python goes in views and HTML goes in
templates. To link the two, Django relies on the render function and the Django Template language.
The Render Function
This function takes three parameters −
Request − The initial request.
The path to the template − This is the path relative to the TEMPLATE_DIRS option in the project
settings.py variables.
Dictionary of parameters − A dictionary that contains all variables needed in the template. This variable
can be created or you can use locals() to pass all local variable declared in the view.
Django Template Language (DTL)
Django’s template engine offers a mini-language to define the user-facing layer of the application.
Displaying Variables
A variable looks like this: {{variable}}. The template replaces the variable by the variable sent by the view
in the third parameter of the render function. Let's change our hello.html to display today’s date −
hello.html
<html>

<body>
Hello World!!!<p>Today is {{today}}</p>
</body>

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

</html>
Then our view will change to −
def hello(request):
today = datetime.datetime.now().date()
return render(request, "hello.html", {"today" : today})
We will now get the following output after accessing the URL/myapp/hello −
Hello World!!!
Today is Sept. 11, 2015
As you have probably noticed, if the variable is not a string, Django will use the __str__ method to display
it; and with the same principle you can access an object attribute just like you do it in Python. For example:
if we wanted to display the date year, my variable would be: {{today.year}}.

Admin Interface:

Django provides a ready-to-use user interface for administrative activities. We all know how an admin
interface is important for a web project. Django automatically generates admin UI based on your project
models.
Starting the Admin Interface
The Admin interface depends on the django.countrib module. To have it working you need to make sure
some modules are imported in the INSTALLED_APPS and MIDDLEWARE_CLASSES tuples of the
myproject/settings.py file.
For INSTALLED_APPS make sure you have −
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
)
For MIDDLEWARE_CLASSES −
MIDDLEWARE_CLASSES = (

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

'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',
)
Before launching your server, to access your Admin Interface, you need to initiate the database −
$ python manage.py migrate
syncdb will create necessary tables or collections depending on your db type, necessary for the admin
interface to run. Even if you don't have a superuser, you will be prompted to create one.
If you already have a superuser or have forgotten it, you can always create one using the following code −
$ python manage.py createsuperuser
Now to start the Admin Interface, we need to make sure we have configured a URL for our admin interface.
Open the myproject/url.py and you should have something like −
from django.conf.urls import patterns, include, url

from django.contrib import admin


admin.autodiscover()

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'myproject.views.home', name = 'home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),
)
Now just run the server.
$ python manage.py runserver
And your admin interface is accessible at: http://127.0.0.1:8000/admin/

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Once connected with your superuser account, you will see the following screen −

That interface will let you administrate Django groups and users, and all registered models in your app. The
interface gives you the ability to do at least the "CRUD" (Create, Read, Update, Delete) operations on your
models.

Form Processing:
Creating forms in Django, is really similar to creating a model. Here again, we just need to inherit from
Django class and the class attributes will be the form fields. Let's add a forms.py file in myapp folder to
contain our app forms. We will create a login form.
myapp/forms.py
#-*- coding: utf-8 -*-
from django import forms

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

class LoginForm(forms.Form):
user = forms.CharField(max_length = 100)
password = forms.CharField(widget = forms.PasswordInput())
As seen above, the field type can take "widget" argument for html rendering; in our case, we want the
password to be hidden, not displayed. Many others widget are present in Django: DateInput for
dates, CheckboxInput for checkboxes, etc.
Using Form in a View
There are two kinds of HTTP requests, GET and POST. In Django, the request object passed as parameter
to your view has an attribute called "method" where the type of the request is set, and all data passed via
POST can be accessed via the request.POST dictionary.
Let's create a login view in our myapp/views.py −
#-*- coding: utf-8 -*-
from myapp.forms import LoginForm

def login(request):
username = "not logged in"

if request.method == "POST":
#Get the posted form
MyLoginForm = LoginForm(request.POST)

if MyLoginForm.is_valid():
username = MyLoginForm.cleaned_data['username']
else:
MyLoginForm = Loginform()

return render(request, 'loggedin.html', {"username" : username})


The view will display the result of the login form posted through the loggedin.html. To test it, we will first
need the login form template. Let's call it login.html.
<html>
<body>

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

<form name = "form" action = "{% url "myapp.views.login" %}"


method = "POST" >{% csrf_token %}

<div style = "max-width:470px;">


<center>
<input type = "text" style = "margin-left:20%;"
placeholder = "Identifiant" name = "username" />
</center>
</div>

<br>

<div style = "max-width:470px;">


<center>
<input type = "password" style = "margin-left:20%;"
placeholder = "password" name = "password" />
</center>
</div>

<br>

<div style = "max-width:470px;">


<center>

<button style = "border:0px; background-color:#4285F4; margin-top:8%;


height:35px; width:80%;margin-left:19%;" type = "submit"
value = "Login" >
<strong>Login</strong>
</button>

</center>

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

</div>

</form>

</body>
</html>
The template will display a login form and post the result to our login view above. You have probably
noticed the tag in the template, which is just to prevent Cross-site Request Forgery (CSRF) attack on your
site.
{% csrf_token %}
Once we have the login template, we need the loggedin.html template that will be rendered after form
treatment.
<html>

<body>
You are : <strong>{{username}}</strong>
</body>

</html>
Now, we just need our pair of URLs to get started: myapp/urls.py
from django.conf.urls import patterns, url
from django.views.generic import TemplateView

urlpatterns = patterns('myapp.views',
url(r'^connection/',TemplateView.as_view(template_name = 'login.html')),
url(r'^login/', 'login', name = 'login'))
When accessing "/myapp/connection", we will get the following login.html template rendered −

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

On the form post, the form is valid. In our case make sure to fill the two fields and you will get −

In case your username is polo, and you forgot the password. You will get the following message −

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Using Our Own Form Validation


In the above example, when validating the form −
MyLoginForm.is_valid()
We only used Django self-form validation engine, in our case just making sure the fields are required. Now
let’s try to make sure the user trying to login is present in our DB as Dreamreal entry. For this, change the
myapp/forms.py to −
#-*- coding: utf-8 -*-
from django import forms
from myapp.models import Dreamreal

class LoginForm(forms.Form):
user = forms.CharField(max_length = 100)
password = forms.CharField(widget = forms.PasswordInput())

def clean_message(self):
username = self.cleaned_data.get("username")
dbuser = Dreamreal.objects.filter(name = username)

if not dbuser:
raise forms.ValidationError("User does not exist in our db!")
return username
Now, after calling the "is_valid" method, we will get the correct output, only if the user is in our database.
If you want to check a field of your form, just add a method starting by "clean_" then your field name to
your form class. Raising a forms.ValidationError is important.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Django settings
A Django settings file contains all the configuration of your Django installation. This document explains
how settings work and which settings are available.
The basics
A settings file is just a Python module with module-level variables.
Here are a couple of example settings:
ALLOWED_HOSTS = ['www.example.com']
DEBUG = False
DEFAULT_FROM_EMAIL = '[email protected]'
Because a settings file is a Python module, the following apply:
It doesn’t allow for Python syntax errors.
It can assign settings dynamically using normal Python syntax. For example:
MY_SETTING = [str(i) for i in range(30)]
It can import values from other settings files.
Designating the settings¶
DJANGO_SETTINGS_MODULE¶
When you use Django, you have to tell it which settings you’re using. Do this by using an environment
variable, DJANGO_SETTINGS_MODULE.
The value of DJANGO_SETTINGS_MODULE should be in Python path syntax, e.g. mysite.settings.
Note that the settings module should be on the Python import search path.
The django-admin utility¶
When using django-admin, you can either set the environment variable once, or explicitly pass in the
settings module each time you run the utility.
Example (Unix Bash shell):
export DJANGO_SETTINGS_MODULE=mysite.settings
django-admin runserver
Example (Windows shell):
set DJANGO_SETTINGS_MODULE=mysite.settings
django-admin runserver
Use the --settings command-line argument to specify the settings manually:
django-admin runserver --settings=mysite.settings
On the server (mod_wsgi)¶
In your live server environment, you’ll need to tell your WSGI application what settings file to use. Do that
with os.environ:

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
Read the Django mod_wsgi documentation for more information and other common elements to a Django
WSGI application.
Default settings¶
A Django settings file doesn’t have to define any settings if it doesn’t need to. Each setting has a sensible
default value. These defaults live in the module django/conf/global_settings.py.
Here’s the algorithm Django uses in compiling settings:
Load settings from global_settings.py.
Load settings from the specified settings file, overriding the global settings as necessary.
Note that a settings file should not import from global_settings, because that’s redundant.
Seeing which settings you’ve changed¶
The command python manage.py diffsettings displays differences between the current settings file and
Django’s default settings.
For more, see the diffsettings documentation.
Using settings in Python code¶
In your Django apps, use settings by importing the object django.conf.settings. Example:
from django.conf import settings

if settings.DEBUG:
# Do something
Note that django.conf.settings isn’t a module – it’s an object. So importing individual settings is not
possible:
from django.conf.settings import DEBUG # This won't work.
Also note that your code should not import from either global_settings or your own settings
file. django.conf.settings abstracts the concepts of default settings and site-specific settings; it presents a
single interface. It also decouples the code that uses settings from the location of your settings.
Altering settings at runtime¶
You shouldn’t alter settings in your applications at runtime. For example, don’t do this in a view:
from django.conf import settings

settings.DEBUG = True # Don't do this!


The only place you should assign to settings is in a settings file.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Security¶
Because a settings file contains sensitive information, such as the database password, you should make
every attempt to limit access to it. For example, change its file permissions so that only you and your Web
server’s user can read it. This is especially important in a shared-hosting environment.
Available settings¶
For a full list of available settings, see the settings reference.
Creating your own settings¶
There’s nothing stopping you from creating your own settings, for your own Django apps, but follow these
guidelines:
Setting names must be all uppercase.
Don’t reinvent an already-existing setting.
For settings that are sequences, Django itself uses lists, but this is only a convention.
Using settings without setting DJANGO_SETTINGS_MODULE¶
In some cases, you might want to bypass the DJANGO_SETTINGS_MODULE environment variable.
For example, if you’re using the template system by itself, you likely don’t want to have to set up an
environment variable pointing to a settings module.
In these cases, you can configure Django’s settings manually. Do this by calling:
django.conf.settings.configure(default_settings, **settings)¶
Example:
from django.conf import settings

settings.configure(DEBUG=True)
Pass configure() as many keyword arguments as you’d like, with each keyword argument representing a
setting and its value. Each argument name should be all uppercase, with the same name as the settings
described above. If a particular setting is not passed to configure() and is needed at some later point,
Django will use the default setting value.
Configuring Django in this fashion is mostly necessary – and, indeed, recommended – when you’re using a
piece of the framework inside a larger application.
Consequently, when configured via settings.configure(), Django will not make any modifications to the
process environment variables (see the documentation of TIME_ZONE for why this would normally
occur). It’s assumed that you’re already in full control of your environment in these cases.
Custom default settings¶
If you’d like default values to come from somewhere other than django.conf.global_settings, you can pass
in a module or class that provides the default settings as the default_settings argument (or as the first
positional argument) in the call to configure().
In this example, default settings are taken from myapp_defaults, and the DEBUG setting is set to True,
regardless of its value in myapp_defaults:

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

from django.conf import settings


from myapp import myapp_defaults

settings.configure(default_settings=myapp_defaults, DEBUG=True)
The following example, which uses myapp_defaults as a positional argument, is equivalent:
settings.configure(myapp_defaults, DEBUG=True)
Normally, you will not need to override the defaults in this fashion. The Django defaults are sufficiently
tame that you can safely use them. Be aware that if you do pass in a new default module, it
entirely replaces the Django defaults, so you must specify a value for every possible setting that might be
used in that code you are importing. Check in django.conf.settings.global_settings for the full list.
Either configure() or DJANGO_SETTINGS_MODULE is required¶
If you’re not setting the DJANGO_SETTINGS_MODULE environment variable,
you must call configure() at some point before using any code that reads settings.
If you don’t set DJANGO_SETTINGS_MODULE and don’t call configure(), Django will raise
an ImportError exception the first time a setting is accessed.
If you set DJANGO_SETTINGS_MODULE, access settings values somehow, then call configure(),
Django will raise a RuntimeError indicating that settings have already been configured. There is a
property for this purpose:
For example:
from django.conf import settings
if not settings.configured:
settings.configure(myapp_defaults, DEBUG=True)
Also, it’s an error to call configure() more than once, or to call configure() after any setting has been
accessed.
It boils down to this: Use exactly one of either configure() or DJANGO_SETTINGS_MODULE. Not
both, and not neither.
Calling django.setup() is required for “standalone” Django usage¶
If you’re using components of Django “standalone” – for example, writing a Python script which loads
some Django templates and renders them, or uses the ORM to fetch some data – there’s one more step
you’ll need in addition to configuring settings.
After you’ve either set DJANGO_SETTINGS_MODULE or called configure(), you’ll need to
call django.setup() to load your settings and populate Django’s application registry. For example:
import django
from django.conf import settings
from myapp import myapp_defaults

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

settings.configure(default_settings=myapp_defaults, DEBUG=True)
django.setup()

# Now this script or any imported module can use any part of Django it needs.
from myapp import models
Note that calling django.setup() is only necessary if your code is truly standalone. When invoked by your
Web server, or through django-admin, Django will handle this for you.

Modules Used In The Projects

The different modules use in this Online Note Share are:

1. Login Module

2. Home module

3. Contact Module

4. User Signup Module

5. User Login Module

6. User Home Page Module

7. Note Upload Module

8. Note delete Module

9. User Home

10. Profile Edit

11. Change Password

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

12. Views Notes

13. Download Notes

14. Admin Login

15. Note verification

16. Admin Home

Home page:

1. This is the page which user see when the open the website.

2. Here user are able to create a new account, do login.

3. Admin also get login in to the site through this page.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

About Page:

 This is the page which show the detail of the website.

 Its tell what for the website is.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Contact Page:

 This is the page where user get all information to establish communication with the
developer.

 It has information like phone no, email, Facebook id , etc.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Login Module:

• Here we can login in 2 different mode

• The first one is Admin login

• The second one is User login.

• All the user can login through this login user name and password.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Admin Page:

• Admin can have a access of all modules

• He/she can make any change in the modules

• He/she have a power to accept and reject the note

• He/she can delete any user, delete any note.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Admin Login:

 This is admin login page.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

 Here admin get login just by entering username and password.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

User SignUp:

• Here the new user create his/her account.

• He/she can create his account using their email , username, user type , branch , course .

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

User Home page:

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

• This is user home page

• This page shows all the information about the user.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Upload Notes:

 Here user can upload the notes just by filling following requirements.

 Here user select his/her file to be uploaded.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

View Notes:

• Here user able to view the notes uploaded by him/her.

• He/she is also able to view the notes uploaded by other user.

• He/she is also able to download the notes

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

Edit Profile:

• User are able to edit his/her account.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

REFERENCE

• www.google.com
• www.Wikipedia.com
• Udemy learning website
• Hub It computer solution institude, Butwal ,Nepal.

Downloaded by Bhagyavant Rajapur ([email protected])


lOMoARcPSD|38596729

THANK
YOU

Downloaded by Bhagyavant Rajapur ([email protected])

You might also like