Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
42 views

Advanced Python Notes (Unit - 1)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Advanced Python Notes (Unit - 1)

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

UNIT – 1

Web Framework – Django

❖ History

➢ Django was created in the autumn of 2003, when the web programmers at the Lawrence
Journal-World newspaper, Adrian Holovaty and Simon Willison, began using Python to
build applications. Jacob Kaplan-Moss was hired early in Django's development shortly
before Simon Willison's internship ended.[16] It was released publicly under a BSD license
in July 2005. The framework was named after guitarist Django Reinhardt.[17] Adrian
Holovaty is a Romani jazz guitar player inspired in part by Reinhardt's music.[18]

➢ In June 2008, it was announced that a newly formed Django Software Foundation (DSF)
would maintain Django in the future.[19]

❖ Introduction

➢ Django is a web application framework written in Python programming language. It is


based on MVT (Model View Template) design pattern. The Django is very demanding
due to its rapid development feature. It takes less time to build application after collecting
client requirement.

❖ Features of Django

• Rapid Development
➢ Django was designed with the intention to make a framework which takes less time to build
web application. The project implementation phase is a very time taken but Django creates
it rapidly.

• Secure
➢ Django takes security seriously and helps developers to avoid many common security
mistakes, such as SQL injection, cross-site scripting, cross-site request forgery etc. Its user
authentication system provides a secure way to manage user accounts and passwords.
• Scalable
➢ Django is scalable in nature and has ability to quickly and flexibly switch from small to
large scale application project

• Fully loaded
➢ Django includes various helping task modules and libraries which can be used to handle
common Web development tasks. Django takes care of user authentication, content
administration, site maps, RSS feeds etc.

• Versatile
➢ Django is versatile in nature which allows it to build applications for different-different
domains. Now a days, Companies are using Django to build various types of applications
like: content management systems, social networks sites or scientific computing platforms
etc.

• Open Source
➢ Django is an open source web application framework. It is publicly available without cost.
It can be downloaded with source code from the public repository. Open source reduces
the total cost of the application development.

• Vast and Supported Community


➢ Django is an one of the most popular web framework. It has widely supportive community
and channels to share and connect.

❖ Drawbacks of MVC Architecture

• Complexity
➢ With time, the MVC architecture pattern updates with a new extent of indirection through
its updates. This further builds up the complexity of the solution. Moreover, the User
Interface Code increases and thus creates an issue while debugging it.

• Cost of Frequent Updates


➢ In the MVC pattern, the views could be overburdened with update requests, if the model
keeps on going with frequent changes. Furthermore, views like graphic displays can take a
longer time to make. As a result, the view component falls behind all the updates.

• Hard to Understand the MVC Architecture


➢ MVC architecture is actually not that easy to learn and understand. Due to its complex
structure and frequent updates, you might find it a bit tricky to keep up with all the
components and the UI code for the same.
• Must have Strict Rules Over the Methods
➢ The third component of the MVC architecture, that is Controller, keeps an eye over the
events that are triggered by the View component. Further, it aims to provide an appropriate
reaction to all these events, which are mostly known as Method. These methods do not
have strict access, which in turn becomes one of the major drawbacks of the MVC.

❖ Why We Use the Django Framework?

• It’s fast and simple


➢ The principles of rapid development, which means coders can do more than one iteration
at a time without starting the whole schedule from scratch
➢ DRY philosophy — Don’t Repeat Yourself — which means programmers can reuse
existing code and focus on the unique one.

• It’s secure
➢ Security is also a high priority for Django. It has one of the best out-of-the-box security
systems out there, and it helps software engineers avoid common security issues, including

• It’s well-established
➢ Django is very good for web development. It is time- and crowd-tested. It has a big,
supportive community accessed through numerous forums, channels, and dedicated
websites. It’s easy to find help when there’s a problematic function in the code and to find
specialists if your company is looking to base the next project on Django.

❖ Django MVT Architecture


➢ Django is based on MVT (Model-View-Template) architecture. MVT is a software
design pattern for developing a web application.

• MVT Structure has the following three parts

Model
➢ The model is going to act as the interface of your data. It is responsible for maintaining
data. It is the logical data structure behind the entire application and is represented by a
database (generally relational databases such as MySql, Postgres)

View
➢ The View is the user interface — what you see in your browser when you render a website.
It is represented by HTML/CSS/Javascript and Jinja files.

Template
➢ A template consists of static parts of the desired HTML output as well as some special
syntax describing how dynamic content will be inserted.
❖ Installation of Django & Create Virtual Environment

• Virtual Environment
➢ It is suggested to have a dedicated virtual environment for each Django project, and one
way to manage a virtual environment is venv, which is included in Python.

➢ The name of the virtual environment is your choice, in this tutorial we will call it myworld.

• Install Virtual Environment library


➢ Pip install virtualenv

• type the following in the command prompt, remember to navigate to where you want
to create your project

➢ py -m venv myworld

• Then you have to activate the environment, by typing this command


➢ myworld\Scripts\activate.bat

❖ Installation of Django
➢ Now, that we have created a virtual environment, we are ready to install Django.
• Install Django
➢ pip install Django
• check Install or Not Django
import django
django.__version__
'5.0.7'

You might also like