SlideShare a Scribd company logo
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

Python Django tutorial | Getting Started With Django | Web Development With D...
Python Django tutorial | Getting Started With Django | Web Development With D...Python Django tutorial | Getting Started With Django | Web Development With D...
Python Django tutorial | Getting Started With Django | Web Development With D...
Edureka!
 
Django Tutorial | Django Web Development With Python | Django Training and Ce...
Django Tutorial | Django Web Development With Python | Django Training and Ce...Django Tutorial | Django Web Development With Python | Django Training and Ce...
Django Tutorial | Django Web Development With Python | Django Training and Ce...
Edureka!
 
Django PPT.pptx
Django PPT.pptxDjango PPT.pptx
Django PPT.pptx
KhyatiBandi1
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
Kishimi Ibrahim Ishaq
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
之宇 趙
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
Max Claus Nunes
 
Python/Django Training
Python/Django TrainingPython/Django Training
Python/Django Training
University of Technology
 
Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...
Zhe Li
 
Introduction to Django Rest Framework
Introduction to Django Rest FrameworkIntroduction to Django Rest Framework
Introduction to Django Rest Framework
bangaloredjangousergroup
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
Rosario Renga
 
Free django
Free djangoFree django
Free django
Eugen Oskin
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
Laurent Duveau
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
Ganga Ram
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
Knoldus Inc.
 
Django Seminar
Django SeminarDjango Seminar
Django Seminar
Yokesh Rana
 
NextJS, A JavaScript Framework for building next generation SPA
NextJS, A JavaScript Framework for building next generation SPA  NextJS, A JavaScript Framework for building next generation SPA
NextJS, A JavaScript Framework for building next generation SPA
Pramendra Gupta
 
Angular 9
Angular 9 Angular 9
Angular 9
Raja Vishnu
 
Laravel Tutorial PPT
Laravel Tutorial PPTLaravel Tutorial PPT
Laravel Tutorial PPT
Piyush Aggarwal
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
Parag Mujumdar
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
Troy Miles
 

What's hot (20)

Python Django tutorial | Getting Started With Django | Web Development With D...
Python Django tutorial | Getting Started With Django | Web Development With D...Python Django tutorial | Getting Started With Django | Web Development With D...
Python Django tutorial | Getting Started With Django | Web Development With D...
 
Django Tutorial | Django Web Development With Python | Django Training and Ce...
Django Tutorial | Django Web Development With Python | Django Training and Ce...Django Tutorial | Django Web Development With Python | Django Training and Ce...
Django Tutorial | Django Web Development With Python | Django Training and Ce...
 
Django PPT.pptx
Django PPT.pptxDjango PPT.pptx
Django PPT.pptx
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Python/Django Training
Python/Django TrainingPython/Django Training
Python/Django Training
 
Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...
 
Introduction to Django Rest Framework
Introduction to Django Rest FrameworkIntroduction to Django Rest Framework
Introduction to Django Rest Framework
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
 
Free django
Free djangoFree django
Free django
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2Routing & Navigating Pages in Angular 2
Routing & Navigating Pages in Angular 2
 
Django Seminar
Django SeminarDjango Seminar
Django Seminar
 
NextJS, A JavaScript Framework for building next generation SPA
NextJS, A JavaScript Framework for building next generation SPA  NextJS, A JavaScript Framework for building next generation SPA
NextJS, A JavaScript Framework for building next generation SPA
 
Angular 9
Angular 9 Angular 9
Angular 9
 
Laravel Tutorial PPT
Laravel Tutorial PPTLaravel Tutorial PPT
Laravel Tutorial PPT
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 

Similar to Introduction to Django

Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django framework
Knoldus Inc.
 
Django by rj
Django by rjDjango by rj
Django
DjangoDjango
Django
sisibeibei
 
Django Workflow and Architecture
Django Workflow and ArchitectureDjango Workflow and Architecture
Django Workflow and Architecture
Andolasoft Inc
 
Django framework
Django frameworkDjango framework
Django framework
Arslan Maqsood
 
Why Django for Web Development
Why Django for Web DevelopmentWhy Django for Web Development
Why Django for Web Development
Morteza Zohoori Shoar
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
fantabulous2024
 
Django Framework Interview Guide - Part 1
Django Framework Interview Guide - Part 1Django Framework Interview Guide - Part 1
Django Framework Interview Guide - Part 1
To Sum It Up
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| Edureka
Edureka!
 
Rapid web application development using django - Part (1)
Rapid web application development using django - Part (1)Rapid web application development using django - Part (1)
Rapid web application development using django - Part (1)
Nishant Soni
 
Basic Python Django
Basic Python DjangoBasic Python Django
Basic Python Django
Kaleem Ullah Mangrio
 
What are the basic key points to focus on while learning Full-stack web devel...
What are the basic key points to focus on while learning Full-stack web devel...What are the basic key points to focus on while learning Full-stack web devel...
What are the basic key points to focus on while learning Full-stack web devel...
kzayra69
 
Introduction To Django
Introduction To DjangoIntroduction To Django
Introduction To Django
Tuan Anh Tran
 
Akash rajguru project report sem v
Akash rajguru project report sem vAkash rajguru project report sem v
Akash rajguru project report sem v
Akash Rajguru
 
React django
React djangoReact django
React django
Heber Silva
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
Haiqi Chen
 
Learn Django Tips, Tricks & Techniques for Developers
Learn Django Tips, Tricks & Techniques for DevelopersLearn Django Tips, Tricks & Techniques for Developers
Learn Django Tips, Tricks & Techniques for Developers
Mars Devs
 
Django framework
Django framework Django framework
Django framework
TIB Academy
 
django
djangodjango
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web Framework
David Gibbons
 

Similar to Introduction to Django (20)

Introduction to django framework
Introduction to django frameworkIntroduction to django framework
Introduction to django framework
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Django
DjangoDjango
Django
 
Django Workflow and Architecture
Django Workflow and ArchitectureDjango Workflow and Architecture
Django Workflow and Architecture
 
Django framework
Django frameworkDjango framework
Django framework
 
Why Django for Web Development
Why Django for Web DevelopmentWhy Django for Web Development
Why Django for Web Development
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
 
Django Framework Interview Guide - Part 1
Django Framework Interview Guide - Part 1Django Framework Interview Guide - Part 1
Django Framework Interview Guide - Part 1
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| Edureka
 
Rapid web application development using django - Part (1)
Rapid web application development using django - Part (1)Rapid web application development using django - Part (1)
Rapid web application development using django - Part (1)
 
Basic Python Django
Basic Python DjangoBasic Python Django
Basic Python Django
 
What are the basic key points to focus on while learning Full-stack web devel...
What are the basic key points to focus on while learning Full-stack web devel...What are the basic key points to focus on while learning Full-stack web devel...
What are the basic key points to focus on while learning Full-stack web devel...
 
Introduction To Django
Introduction To DjangoIntroduction To Django
Introduction To Django
 
Akash rajguru project report sem v
Akash rajguru project report sem vAkash rajguru project report sem v
Akash rajguru project report sem v
 
React django
React djangoReact django
React django
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
Learn Django Tips, Tricks & Techniques for Developers
Learn Django Tips, Tricks & Techniques for DevelopersLearn Django Tips, Tricks & Techniques for Developers
Learn Django Tips, Tricks & Techniques for Developers
 
Django framework
Django framework Django framework
Django framework
 
django
djangodjango
django
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web Framework
 

More from Ahmed Salama

Seven Ways To Be a Healthy Programmer!.pdf
Seven Ways To Be a Healthy Programmer!.pdfSeven Ways To Be a Healthy Programmer!.pdf
Seven Ways To Be a Healthy Programmer!.pdf
Ahmed Salama
 
10 Code Anti-Patterns to Avoid in Software Development.pdf
10 Code Anti-Patterns to Avoid in Software Development.pdf10 Code Anti-Patterns to Avoid in Software Development.pdf
10 Code Anti-Patterns to Avoid in Software Development.pdf
Ahmed Salama
 
Introduction to web development
Introduction to web developmentIntroduction to web development
Introduction to web development
Ahmed Salama
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ahmed Salama
 
Quick Start to marketing.
Quick Start to marketing.Quick Start to marketing.
Quick Start to marketing.
Ahmed Salama
 
Distributed database
Distributed databaseDistributed database
Distributed database
Ahmed Salama
 
Konard zuse
Konard zuseKonard zuse
Konard zuse
Ahmed Salama
 
DDOS Attack
DDOS Attack DDOS Attack
DDOS Attack
Ahmed Salama
 
Introduction to Computer Science Department
Introduction to Computer Science DepartmentIntroduction to Computer Science Department
Introduction to Computer Science Department
Ahmed Salama
 

More from Ahmed Salama (9)

Seven Ways To Be a Healthy Programmer!.pdf
Seven Ways To Be a Healthy Programmer!.pdfSeven Ways To Be a Healthy Programmer!.pdf
Seven Ways To Be a Healthy Programmer!.pdf
 
10 Code Anti-Patterns to Avoid in Software Development.pdf
10 Code Anti-Patterns to Avoid in Software Development.pdf10 Code Anti-Patterns to Avoid in Software Development.pdf
10 Code Anti-Patterns to Avoid in Software Development.pdf
 
Introduction to web development
Introduction to web developmentIntroduction to web development
Introduction to web development
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Quick Start to marketing.
Quick Start to marketing.Quick Start to marketing.
Quick Start to marketing.
 
Distributed database
Distributed databaseDistributed database
Distributed database
 
Konard zuse
Konard zuseKonard zuse
Konard zuse
 
DDOS Attack
DDOS Attack DDOS Attack
DDOS Attack
 
Introduction to Computer Science Department
Introduction to Computer Science DepartmentIntroduction to Computer Science Department
Introduction to Computer Science Department
 

Recently uploaded

AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 

Recently uploaded (20)

AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 

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

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