SlideShare a Scribd company logo
3
Most read
4
Most read
10
Most read
Introduction to Django
Presented by: Ahmed Salama
Software Engineer at Ibtikar Technologies
A web development framework for Python
● What is Django?
● History
● MVC and MVT design patterns
● Django Architecture
TOC
● Django Modules
● Install Django
● Steps to create Django project
● Let’s make a small ToDo App
What does “Django” means?
● Django is named after Django Reinhardt, a jazz manouche guitarist from
the 1930s to early 1950s. To this day, he’s considered one of the best
guitarists of all time.
● Django is pronounced JANG-oh. Rhymes with FANG-oh. The “D” is silent.
Django is a free open source Web frameworks written in python
1
2
3
History
● Created in 2003, When the Web programmers at Lawrence Journal-World
newspaper, Adrian Holovaty and Simon Willison, began using Python to build
applications.
● It was released publicly in 2008, Official site: https://www.djangoproject.com/
● Django’s now run by an international team of volunteers.
● Which sites use Django?? DjangoSites.org contains list of django websites and you
can register yours.
● Well-known sites: Disqus - BitBucket - Instagram - Mozilla Firefox(help page, Add-
ons ) - Pinterest( 33 million visit per month) - NASA - Onion(satirical articles) - The
washington post - eventbrite
Model-View-Controller(MVC) Design pattern
● Model: A representation of your data. It’s not the actual data, but an interface to the data. It allows you to pull data
from your database without knowing the intricacies of the underlying database(ORM).
● View: What you see in the browser. It’s the presentation layer for your model.
● Controller: controls the flow of information between the model and the view. It uses programmed logic to decide
what information is pulled from the database via the model and what information is passed to the view.
Model-View-Template(MTV) Design pattern
● Model: Data access layer.
● Template: The presentation layer. (Takes the role of ‘View’ on MVC)
● View: the business logic layer. Controls what a user sees. This layer contains the logic that accesses the model and
defers to the appropriate template(s). You can think of it as the bridge between models and templates.
● The controller role is handled by the Framework itself and this is the most advantage of Django’s MVC.
Django Modules
★ Administration interface (CRUD interface)
★ Authentication system
★ Comments system
★ Forms handling
★ Sessions
★ Syndication framework (RSS and Atom Feeds)
★ Caching
★ Internationalization
★ Localization
★ Custom Middleware
Why Django for Web development?
● Provides auto generated web admin to ease the website administration.
● Provides you template system to define HTML template for your web pages to
avoid code duplication.
● Allows you to define what URL be for a given Function.
● Everything is in python.
● Django is not only one of many web frameworks available. It is one of the
leading frameworks for developing scalable, secure and maintainable web
applications.
Install Django
● Install python > $ sudo apt-get install python3
● Install pip > $ sudo apt-get install python3-pip
● Install virtualenv > $ pip3 install virtualenv
● Install Django > $ pip install django
Follow thes steps: https://www.digitalocean.com/community/tutorials/how-to-install-django-and-set-up-a-development-
environment-on-ubuntu-16-04
Steps to create Django project
➢ Start a project $ django-admin startproject <project_name>
➢ Start an application $ python manage.py startapp <app_name>
➢ Define your models # models.py
➢ Write your templates templates/
➢ Define your views # views.py
➢ Create URL mapping # urls.py
➢ Test Application # test.py
➢ Edit the Django’s default database(SQLite) to MySQL or Postgresql -if you want.
➢ Define DB Settings in Settings.py
➢ Deploy Application -make it public(Heroku, etc.)
Django’s generated code (Starter code)
> MyProject/
> MyProject/
> __init__.py -> Call wsgi.py
> settings.py -> Configuration file
> urls.py -> URL Mapping for the project
> wsgi.py -> The start point of the project
> MyApp/
> __init__.py
> migrations/ -> History(Versions) of database changes
> admin.py -> Register your models here(add them to admin website)
> apps.py
> tests.py
> models.py
> views.py
> manage.py -> Interact with django( runserver, migrate(commit changes to database)
..)
Add to the starter code..
● Import application’s view.py in urls.py. < from myApp import views as app1_views>
Append functions to urls < path('home/', app1_views.index, name='index'), >
● Add your application to intalled_apps array which in settings.py > to add it to admin site.
● Templates/ directory contains the html files of each application. < os.path.join(BASE_DIR, ‘templates’) >
● Staticfiles/ directory to add css, js, img files to it. <STATICFILES_DIRS = [ os.path.join(BASE_DIR, "staticfiles"), ] >
● Create the Admin website > $python3 manage.py migrate
● Create super user( system admin) > $ python3 manage.py createsuperuser
● Design Error pages (400, 403, 404, 500) -Django take care of it in local development.
● Adjust the settings file for production(deployment)
Run Django’s server with $ python3 manage.py runserver
Let’s make a small project!
ToDo Application
1- TaskModel has: Name, Description, Owner(foreignKey), Responsibles(Many2one), is_done.
2- Color it with ‘staticfiles’.
3- add/remove tasks from admin site.
Further reading & Resources
● Django Documentations: https://docs.djangoproject.com/en/2.1/
● Udemy course: https://www.udemy.com/python-ecommerce-build-a-django-ecommerce-web-application/
● The Django Book: https://djangobook.com/
● Django Girls: https://djangogirls.org/ ( We inspire women to fall in love with programming.)
Thanks!

More Related Content

What's hot (20)

PPTX
Django PPT.pptx
KhyatiBandi1
 
PDF
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
Edureka!
 
PPTX
MVVM - Model View ViewModel
Dareen Alhiyari
 
PPTX
Django Framework Overview forNon-Python Developers
Rosario Renga
 
PDF
D2 domain driven-design
Arnaud Bouchez
 
PDF
CONTINUOUS INTEGRATION WITH JENKINS AND GIT
Benjamin Lutaaya
 
PPT
Core java
kasaragaddaslide
 
PPTX
Introduction to angular with a simple but complete project
Jadson Santos
 
PPTX
Introduction to Node js
Akshay Mathur
 
PPT
Developing an ASP.NET Web Application
Rishi Kothari
 
PPTX
Spring Boot Tutorial
Naphachara Rattanawilai
 
PDF
Spring Boot
Jaran Flaath
 
PPTX
LINQ in C#
Basant Medhat
 
PPTX
Spring Security 5
Jesus Perez Franco
 
PPTX
Presentation on "An Introduction to ReactJS"
Flipkart
 
PPTX
Dependency injection presentation
Ahasanul Kalam Akib
 
PDF
Building blocks of Angular
Knoldus Inc.
 
PDF
Spring MVC Framework
Hùng Nguyễn Huy
 
PPTX
ASP.NET Web API
habib_786
 
Django PPT.pptx
KhyatiBandi1
 
What is Node.js | Node.js Tutorial for Beginners | Node.js Modules | Node.js ...
Edureka!
 
MVVM - Model View ViewModel
Dareen Alhiyari
 
Django Framework Overview forNon-Python Developers
Rosario Renga
 
D2 domain driven-design
Arnaud Bouchez
 
CONTINUOUS INTEGRATION WITH JENKINS AND GIT
Benjamin Lutaaya
 
Core java
kasaragaddaslide
 
Introduction to angular with a simple but complete project
Jadson Santos
 
Introduction to Node js
Akshay Mathur
 
Developing an ASP.NET Web Application
Rishi Kothari
 
Spring Boot Tutorial
Naphachara Rattanawilai
 
Spring Boot
Jaran Flaath
 
LINQ in C#
Basant Medhat
 
Spring Security 5
Jesus Perez Franco
 
Presentation on "An Introduction to ReactJS"
Flipkart
 
Dependency injection presentation
Ahasanul Kalam Akib
 
Building blocks of Angular
Knoldus Inc.
 
Spring MVC Framework
Hùng Nguyễn Huy
 
ASP.NET Web API
habib_786
 

Similar to Introduction to Django (20)

PPTX
Basic Python Django
Kaleem Ullah Mangrio
 
PDF
Django Workflow and Architecture
Andolasoft Inc
 
PDF
Django
sisibeibei
 
PPTX
Web development with django - Basics Presentation
Shrinath Shenoy
 
PDF
Web development django.pdf
KomalSaini178773
 
PDF
Django Documentation
Ying wei (Joe) Chou
 
PDF
بررسی چارچوب جنگو
railsbootcamp
 
PPTX
Why Django for Web Development
Morteza Zohoori Shoar
 
PDF
Django tutorial
HarikaReddy115
 
PDF
Introduction to Django Course For Newbie - Advance
yusufvabdullah001
 
PPTX
1-_Introduction_To_Django_Model_and_Database (1).pptx
TamilGamers4
 
PPTX
Django
Abhijeet Shekhar
 
PPTX
django part-1
Gaurav Dixit
 
PDF
Step-by-Step Django Web Development with Python
Shiv Technolabs Pvt. Ltd.
 
PPTX
Django Architecture Introduction
Haiqi Chen
 
PDF
Django in Action (MEAP V01) Christopher Trudeau
dsmplwegv4530
 
PDF
Introduction to django framework
Knoldus Inc.
 
PPTX
Django Girls Tutorial
Kishimi Ibrahim Ishaq
 
PDF
Django
Narcisse Siewe
 
Basic Python Django
Kaleem Ullah Mangrio
 
Django Workflow and Architecture
Andolasoft Inc
 
Django
sisibeibei
 
Web development with django - Basics Presentation
Shrinath Shenoy
 
Web development django.pdf
KomalSaini178773
 
Django Documentation
Ying wei (Joe) Chou
 
بررسی چارچوب جنگو
railsbootcamp
 
Why Django for Web Development
Morteza Zohoori Shoar
 
Django tutorial
HarikaReddy115
 
Introduction to Django Course For Newbie - Advance
yusufvabdullah001
 
1-_Introduction_To_Django_Model_and_Database (1).pptx
TamilGamers4
 
django part-1
Gaurav Dixit
 
Step-by-Step Django Web Development with Python
Shiv Technolabs Pvt. Ltd.
 
Django Architecture Introduction
Haiqi Chen
 
Django in Action (MEAP V01) Christopher Trudeau
dsmplwegv4530
 
Introduction to django framework
Knoldus Inc.
 
Django Girls Tutorial
Kishimi Ibrahim Ishaq
 
Ad

More from Ahmed Salama (10)

PPTX
Introduction to Computer science and its fields
Ahmed Salama
 
PDF
Seven Ways To Be a Healthy Programmer!.pdf
Ahmed Salama
 
PDF
10 Code Anti-Patterns to Avoid in Software Development.pdf
Ahmed Salama
 
PPTX
Introduction to web development
Ahmed Salama
 
PDF
Introduction to python
Ahmed Salama
 
PDF
Quick Start to marketing.
Ahmed Salama
 
PPT
Distributed database
Ahmed Salama
 
PPTX
Konard zuse
Ahmed Salama
 
PPT
DDOS Attack
Ahmed Salama
 
PDF
Introduction to Computer Science Department
Ahmed Salama
 
Introduction to Computer science and its fields
Ahmed Salama
 
Seven Ways To Be a Healthy Programmer!.pdf
Ahmed Salama
 
10 Code Anti-Patterns to Avoid in Software Development.pdf
Ahmed Salama
 
Introduction to web development
Ahmed Salama
 
Introduction to python
Ahmed Salama
 
Quick Start to marketing.
Ahmed Salama
 
Distributed database
Ahmed Salama
 
Konard zuse
Ahmed Salama
 
DDOS Attack
Ahmed Salama
 
Introduction to Computer Science Department
Ahmed Salama
 
Ad

Recently uploaded (20)

PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 

Introduction to Django

  • 1. Introduction to Django Presented by: Ahmed Salama Software Engineer at Ibtikar Technologies A web development framework for Python
  • 2. ● What is Django? ● History ● MVC and MVT design patterns ● Django Architecture TOC ● Django Modules ● Install Django ● Steps to create Django project ● Let’s make a small ToDo App
  • 3. What does “Django” means? ● Django is named after Django Reinhardt, a jazz manouche guitarist from the 1930s to early 1950s. To this day, he’s considered one of the best guitarists of all time. ● Django is pronounced JANG-oh. Rhymes with FANG-oh. The “D” is silent. Django is a free open source Web frameworks written in python 1 2 3
  • 4. History ● Created in 2003, When the Web programmers at Lawrence Journal-World newspaper, Adrian Holovaty and Simon Willison, began using Python to build applications. ● It was released publicly in 2008, Official site: https://www.djangoproject.com/ ● Django’s now run by an international team of volunteers. ● Which sites use Django?? DjangoSites.org contains list of django websites and you can register yours. ● Well-known sites: Disqus - BitBucket - Instagram - Mozilla Firefox(help page, Add- ons ) - Pinterest( 33 million visit per month) - NASA - Onion(satirical articles) - The washington post - eventbrite
  • 5. Model-View-Controller(MVC) Design pattern ● Model: A representation of your data. It’s not the actual data, but an interface to the data. It allows you to pull data from your database without knowing the intricacies of the underlying database(ORM). ● View: What you see in the browser. It’s the presentation layer for your model. ● Controller: controls the flow of information between the model and the view. It uses programmed logic to decide what information is pulled from the database via the model and what information is passed to the view.
  • 6. Model-View-Template(MTV) Design pattern ● Model: Data access layer. ● Template: The presentation layer. (Takes the role of ‘View’ on MVC) ● View: the business logic layer. Controls what a user sees. This layer contains the logic that accesses the model and defers to the appropriate template(s). You can think of it as the bridge between models and templates. ● The controller role is handled by the Framework itself and this is the most advantage of Django’s MVC.
  • 7. Django Modules ★ Administration interface (CRUD interface) ★ Authentication system ★ Comments system ★ Forms handling ★ Sessions ★ Syndication framework (RSS and Atom Feeds) ★ Caching ★ Internationalization ★ Localization ★ Custom Middleware
  • 8. Why Django for Web development? ● Provides auto generated web admin to ease the website administration. ● Provides you template system to define HTML template for your web pages to avoid code duplication. ● Allows you to define what URL be for a given Function. ● Everything is in python. ● Django is not only one of many web frameworks available. It is one of the leading frameworks for developing scalable, secure and maintainable web applications.
  • 9. Install Django ● Install python > $ sudo apt-get install python3 ● Install pip > $ sudo apt-get install python3-pip ● Install virtualenv > $ pip3 install virtualenv ● Install Django > $ pip install django Follow thes steps: https://www.digitalocean.com/community/tutorials/how-to-install-django-and-set-up-a-development- environment-on-ubuntu-16-04
  • 10. Steps to create Django project ➢ Start a project $ django-admin startproject <project_name> ➢ Start an application $ python manage.py startapp <app_name> ➢ Define your models # models.py ➢ Write your templates templates/ ➢ Define your views # views.py ➢ Create URL mapping # urls.py ➢ Test Application # test.py ➢ Edit the Django’s default database(SQLite) to MySQL or Postgresql -if you want. ➢ Define DB Settings in Settings.py ➢ Deploy Application -make it public(Heroku, etc.)
  • 11. Django’s generated code (Starter code) > MyProject/ > MyProject/ > __init__.py -> Call wsgi.py > settings.py -> Configuration file > urls.py -> URL Mapping for the project > wsgi.py -> The start point of the project > MyApp/ > __init__.py > migrations/ -> History(Versions) of database changes > admin.py -> Register your models here(add them to admin website) > apps.py > tests.py > models.py > views.py > manage.py -> Interact with django( runserver, migrate(commit changes to database) ..)
  • 12. Add to the starter code.. ● Import application’s view.py in urls.py. < from myApp import views as app1_views> Append functions to urls < path('home/', app1_views.index, name='index'), > ● Add your application to intalled_apps array which in settings.py > to add it to admin site. ● Templates/ directory contains the html files of each application. < os.path.join(BASE_DIR, ‘templates’) > ● Staticfiles/ directory to add css, js, img files to it. <STATICFILES_DIRS = [ os.path.join(BASE_DIR, "staticfiles"), ] > ● Create the Admin website > $python3 manage.py migrate ● Create super user( system admin) > $ python3 manage.py createsuperuser ● Design Error pages (400, 403, 404, 500) -Django take care of it in local development. ● Adjust the settings file for production(deployment) Run Django’s server with $ python3 manage.py runserver
  • 13. Let’s make a small project! ToDo Application 1- TaskModel has: Name, Description, Owner(foreignKey), Responsibles(Many2one), is_done. 2- Color it with ‘staticfiles’. 3- add/remove tasks from admin site.
  • 14. Further reading & Resources ● Django Documentations: https://docs.djangoproject.com/en/2.1/ ● Udemy course: https://www.udemy.com/python-ecommerce-build-a-django-ecommerce-web-application/ ● The Django Book: https://djangobook.com/ ● Django Girls: https://djangogirls.org/ ( We inspire women to fall in love with programming.)

Editor's Notes

  • #13: 400> Bad request 403> Permission denied 404> page not found 500> server down
  • #14: Owner = models.foreignKey(‘auth.user’, on_delete=models.CASCADE) Responsibles = models.