SlideShare une entreprise Scribd logo
1  sur  11
OutLine…
• What is Django?
• Django ad MVC Desing pattern
• Django Architecture
• Why Django for Web Development
• Steps to create new project
• What Django generates
• Sample Application
What is Django?
• “Django is a high-level Python Web framework that
encourages rapid development and clean, pragmatic
design”
Django ad MVC Desing pattern
• MVT Architecture:
Models:Describes your data structure/database schema
Views:Controls What a user sees
Templates:How a user sees it
Controller:The Django framework – URL Parsing
Django Architecture
Why Django for Web Development
• Lets you divide code modules into logical groups to make it
flexible to change…MVT design pattern
• Provides auto generate web admin to ease the website
administration
• Provides pre-packaged API for common user tasks
• Provide your 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 (schema/settings)
Steps to create New Project
 Create a project
 Start an application
 Create the database (MySQL, Postgresql, SQLite)
 Define DB Settings in Settings.py
 Define your models
 Add pluggable modules
 Write your templates
 Define your views
 Create URL mapping
 Test Application
 Deploy Application (Linux, Apache, mod_Python, DB)
What Django generates
mysite/
manage.py
mysite/
django-admin.py startproject mysite __init__.py
settings.py
urls.py
wsgi.py
polls/
__init__.py
admin.py
python manage.py startapp blog migrations/
__init__.py
models.py
tests.py
views.py
Create a project
Start an application
blog/models.py file so it looks like this:
class Post(models.Model):
title = models.CharField(max_length=100,unique=True)
slug = models.SlugField(max_length=100,unique=True)
content = HTMLField()
created = models.DateTimeField(db_index=True)
meta_desc = models.CharField(max_length=150,blank=True)
author = models.ForeignKey(User)
category = models.ForeignKey('Category')
published = models.BooleanField(default=False)
tags = TaggableManager()
def __unicode__(self):
return "%s" % self.title
def get_absolute_url(self):
return reverse('showpost',args=[str(self.category.slug),str(self.slug)])
blog/views.py file so it looks like this:
def main(request):
"""Main listing."""
posts = Post.objects.all().order_by("-created")
paginator = Paginator(posts, 4)
try: page = int(request.GET.get("page", '1'))
except ValueError: page = 1
try:
posts = paginator.page(page)
except (InvalidPage, EmptyPage):
posts = paginator.page(paginator.num_pages)
return render_to_response("postlist.html", dict(posts=posts, user=request.user))
class IndexView(ListView):
queryset = Post.objects.filter(published=True).order_by('-created')
Thanks!
life is short - you need Python!
@py_Django
@Morteza Dariushi

Contenu connexe

Tendances

Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsBastian Hofmann
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowPrabhdeep Singh
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introductionTomi Juhola
 
Integrating Plone with E-Commerce and Relationship Management: A Case Study i...
Integrating Plone with E-Commerce and Relationship Management: A Case Study i...Integrating Plone with E-Commerce and Relationship Management: A Case Study i...
Integrating Plone with E-Commerce and Relationship Management: A Case Study i...David Glick
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSHannes Hapke
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030Kevin Wu
 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Ayes Chinmay
 
Templates
TemplatesTemplates
Templatessoon
 
Html 5 in a big nutshell
Html 5 in a big nutshellHtml 5 in a big nutshell
Html 5 in a big nutshellLennart Schoors
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax ApplicationsJulien Lecomte
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsBG Java EE Course
 
1 ppt-ajax with-j_query
1 ppt-ajax with-j_query1 ppt-ajax with-j_query
1 ppt-ajax with-j_queryFajar Baskoro
 
Experience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsExperience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsCédric Hüsler
 
Html server control - ASP. NET with c#
Html server control - ASP. NET with c#Html server control - ASP. NET with c#
Html server control - ASP. NET with c#priya Nithya
 

Tendances (19)

Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
Django
DjangoDjango
Django
 
Integrating Plone with E-Commerce and Relationship Management: A Case Study i...
Integrating Plone with E-Commerce and Relationship Management: A Case Study i...Integrating Plone with E-Commerce and Relationship Management: A Case Study i...
Integrating Plone with E-Commerce and Relationship Management: A Case Study i...
 
Wt unit 6 ppts web services
Wt unit 6 ppts web servicesWt unit 6 ppts web services
Wt unit 6 ppts web services
 
19servlets
19servlets19servlets
19servlets
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJS
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030
 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
 
Templates
TemplatesTemplates
Templates
 
Angular js
Angular jsAngular js
Angular js
 
Html 5 in a big nutshell
Html 5 in a big nutshellHtml 5 in a big nutshell
Html 5 in a big nutshell
 
Wicket 2010
Wicket 2010Wicket 2010
Wicket 2010
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 
1 ppt-ajax with-j_query
1 ppt-ajax with-j_query1 ppt-ajax with-j_query
1 ppt-ajax with-j_query
 
Experience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsExperience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - Highlights
 
Html server control - ASP. NET with c#
Html server control - ASP. NET with c#Html server control - ASP. NET with c#
Html server control - ASP. NET with c#
 

En vedette

Edte 314 presentation week 3
Edte 314 presentation week 3Edte 314 presentation week 3
Edte 314 presentation week 3Jess Hall
 
Extending WordPress' TinyMCE
Extending WordPress' TinyMCEExtending WordPress' TinyMCE
Extending WordPress' TinyMCEHristo Chakarov
 
Finding and understanding patterns in distant reading.
Finding and understanding patterns in distant reading.Finding and understanding patterns in distant reading.
Finding and understanding patterns in distant reading.Ted Underwood
 
Trend journal 1 the space age resurfaces
Trend journal 1   the space age resurfacesTrend journal 1   the space age resurfaces
Trend journal 1 the space age resurfacesAidenn Mullen
 
Busi 710 final slidedeck
Busi 710 final slidedeckBusi 710 final slidedeck
Busi 710 final slidedeckAidenn Mullen
 
Design thinking project plan draft for Apex
Design thinking project plan draft for ApexDesign thinking project plan draft for Apex
Design thinking project plan draft for ApexAidenn Mullen
 
Contextual Research design brief
Contextual Research design brief Contextual Research design brief
Contextual Research design brief Aidenn Mullen
 
Ethnographic research final - graduate design management
Ethnographic research final - graduate design management Ethnographic research final - graduate design management
Ethnographic research final - graduate design management Aidenn Mullen
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play NiceAlex Gaynor
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersRosario Renga
 
Desenvolvimento web simples com Python e DJango
Desenvolvimento web simples com Python e DJangoDesenvolvimento web simples com Python e DJango
Desenvolvimento web simples com Python e DJangoRafael Nunes
 
Synthesis and targetting of mitochondrial proteins
Synthesis and targetting of mitochondrial proteinsSynthesis and targetting of mitochondrial proteins
Synthesis and targetting of mitochondrial proteinsAjay Badyal
 
Python e Django na Globo.com
Python e Django na Globo.comPython e Django na Globo.com
Python e Django na Globo.comricobl
 

En vedette (13)

Edte 314 presentation week 3
Edte 314 presentation week 3Edte 314 presentation week 3
Edte 314 presentation week 3
 
Extending WordPress' TinyMCE
Extending WordPress' TinyMCEExtending WordPress' TinyMCE
Extending WordPress' TinyMCE
 
Finding and understanding patterns in distant reading.
Finding and understanding patterns in distant reading.Finding and understanding patterns in distant reading.
Finding and understanding patterns in distant reading.
 
Trend journal 1 the space age resurfaces
Trend journal 1   the space age resurfacesTrend journal 1   the space age resurfaces
Trend journal 1 the space age resurfaces
 
Busi 710 final slidedeck
Busi 710 final slidedeckBusi 710 final slidedeck
Busi 710 final slidedeck
 
Design thinking project plan draft for Apex
Design thinking project plan draft for ApexDesign thinking project plan draft for Apex
Design thinking project plan draft for Apex
 
Contextual Research design brief
Contextual Research design brief Contextual Research design brief
Contextual Research design brief
 
Ethnographic research final - graduate design management
Ethnographic research final - graduate design management Ethnographic research final - graduate design management
Ethnographic research final - graduate design management
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play Nice
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
 
Desenvolvimento web simples com Python e DJango
Desenvolvimento web simples com Python e DJangoDesenvolvimento web simples com Python e DJango
Desenvolvimento web simples com Python e DJango
 
Synthesis and targetting of mitochondrial proteins
Synthesis and targetting of mitochondrial proteinsSynthesis and targetting of mitochondrial proteins
Synthesis and targetting of mitochondrial proteins
 
Python e Django na Globo.com
Python e Django na Globo.comPython e Django na Globo.com
Python e Django na Globo.com
 

Similaire à Why Django for Web Development

Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to djangoIlian Iliev
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web FrameworkDavid Gibbons
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoAhmed Salama
 
Mezzanine簡介 (at) Taichung.py
Mezzanine簡介 (at) Taichung.pyMezzanine簡介 (at) Taichung.py
Mezzanine簡介 (at) Taichung.pyMax Lai
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Joe Wilson
 
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]Udit Gangwani
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGiuliano Iacobelli
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| EdurekaEdureka!
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگوrailsbootcamp
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJoaquim Rocha
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Anupam Ranku
 

Similaire à Why Django for Web Development (20)

Django
DjangoDjango
Django
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
Introduction to django
Introduction to djangoIntroduction to django
Introduction to django
 
Sahil_18118_IOT-ppt.pptx
Sahil_18118_IOT-ppt.pptxSahil_18118_IOT-ppt.pptx
Sahil_18118_IOT-ppt.pptx
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web Framework
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Mezzanine簡介 (at) Taichung.py
Mezzanine簡介 (at) Taichung.pyMezzanine簡介 (at) Taichung.py
Mezzanine簡介 (at) Taichung.py
 
Asp.Net MVC 5 in Arabic
Asp.Net MVC 5 in ArabicAsp.Net MVC 5 in Arabic
Asp.Net MVC 5 in Arabic
 
Mini Curso de Django
Mini Curso de DjangoMini Curso de Django
Mini Curso de Django
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC Introduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
Django apps and ORM Beyond the basics [Meetup hosted by Prodeers.com]
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
 
Tango with django
Tango with djangoTango with django
Tango with django
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| Edureka
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
 

Dernier

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 

Dernier (20)

Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 

Why Django for Web Development

  • 1.
  • 2. OutLine… • What is Django? • Django ad MVC Desing pattern • Django Architecture • Why Django for Web Development • Steps to create new project • What Django generates • Sample Application
  • 3. What is Django? • “Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design”
  • 4. Django ad MVC Desing pattern • MVT Architecture: Models:Describes your data structure/database schema Views:Controls What a user sees Templates:How a user sees it Controller:The Django framework – URL Parsing
  • 6. Why Django for Web Development • Lets you divide code modules into logical groups to make it flexible to change…MVT design pattern • Provides auto generate web admin to ease the website administration • Provides pre-packaged API for common user tasks • Provide your 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 (schema/settings)
  • 7. Steps to create New Project  Create a project  Start an application  Create the database (MySQL, Postgresql, SQLite)  Define DB Settings in Settings.py  Define your models  Add pluggable modules  Write your templates  Define your views  Create URL mapping  Test Application  Deploy Application (Linux, Apache, mod_Python, DB)
  • 8. What Django generates mysite/ manage.py mysite/ django-admin.py startproject mysite __init__.py settings.py urls.py wsgi.py polls/ __init__.py admin.py python manage.py startapp blog migrations/ __init__.py models.py tests.py views.py Create a project Start an application
  • 9. blog/models.py file so it looks like this: class Post(models.Model): title = models.CharField(max_length=100,unique=True) slug = models.SlugField(max_length=100,unique=True) content = HTMLField() created = models.DateTimeField(db_index=True) meta_desc = models.CharField(max_length=150,blank=True) author = models.ForeignKey(User) category = models.ForeignKey('Category') published = models.BooleanField(default=False) tags = TaggableManager() def __unicode__(self): return "%s" % self.title def get_absolute_url(self): return reverse('showpost',args=[str(self.category.slug),str(self.slug)])
  • 10. blog/views.py file so it looks like this: def main(request): """Main listing.""" posts = Post.objects.all().order_by("-created") paginator = Paginator(posts, 4) try: page = int(request.GET.get("page", '1')) except ValueError: page = 1 try: posts = paginator.page(page) except (InvalidPage, EmptyPage): posts = paginator.page(paginator.num_pages) return render_to_response("postlist.html", dict(posts=posts, user=request.user)) class IndexView(ListView): queryset = Post.objects.filter(published=True).order_by('-created')
  • 11. Thanks! life is short - you need Python! @py_Django @Morteza Dariushi