SlideShare a Scribd company logo
Why Django for Web Development
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

More Related Content

What's hot (19)

PDF
Opening up the Social Web - Standards that are bridging the Islands
Bastian Hofmann
 
PPTX
HTL(Sightly) - All you need to know
Prabhdeep Singh
 
PPT
jQuery introduction
Tomi Juhola
 
PDF
Django
Amanpreet Singh
 
PDF
Integrating Plone with E-Commerce and Relationship Management: A Case Study i...
David Glick
 
PDF
19servlets
Adil Jafri
 
PDF
Create responsive websites with Django, REST and AngularJS
Hannes Hapke
 
PDF
django_introduction20141030
Kevin Wu
 
PPTX
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Ayes Chinmay
 
KEY
Templates
soon
 
DOCX
Angular js
prasaddammalapati
 
PDF
Html 5 in a big nutshell
Lennart Schoors
 
KEY
Wicket 2010
Martijn Dashorst
 
PPT
High Performance Ajax Applications
Julien Lecomte
 
ODP
JavaScript and jQuery Fundamentals
BG Java EE Course
 
PDF
1 ppt-ajax with-j_query
Fajar Baskoro
 
PDF
Experience Manager 6 Developer Features - Highlights
Cédric Hüsler
 
PDF
Html server control - ASP. NET with c#
priya Nithya
 
Opening up the Social Web - Standards that are bridging the Islands
Bastian Hofmann
 
HTL(Sightly) - All you need to know
Prabhdeep Singh
 
jQuery introduction
Tomi Juhola
 
Integrating Plone with E-Commerce and Relationship Management: A Case Study i...
David Glick
 
19servlets
Adil Jafri
 
Create responsive websites with Django, REST and AngularJS
Hannes Hapke
 
django_introduction20141030
Kevin Wu
 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Ayes Chinmay
 
Templates
soon
 
Angular js
prasaddammalapati
 
Html 5 in a big nutshell
Lennart Schoors
 
Wicket 2010
Martijn Dashorst
 
High Performance Ajax Applications
Julien Lecomte
 
JavaScript and jQuery Fundamentals
BG Java EE Course
 
1 ppt-ajax with-j_query
Fajar Baskoro
 
Experience Manager 6 Developer Features - Highlights
Cédric Hüsler
 
Html server control - ASP. NET with c#
priya Nithya
 

Viewers also liked (13)

PPTX
Edte 314 presentation week 3
Jess Hall
 
PDF
Extending WordPress' TinyMCE
Hristo Chakarov
 
PPTX
Finding and understanding patterns in distant reading.
Ted Underwood
 
PDF
Trend journal 1 the space age resurfaces
Aidenn Mullen
 
PDF
Busi 710 final slidedeck
Aidenn Mullen
 
PDF
Design thinking project plan draft for Apex
Aidenn Mullen
 
PDF
Contextual Research design brief
Aidenn Mullen
 
PDF
Ethnographic research final - graduate design management
Aidenn Mullen
 
KEY
Making Django and NoSQL Play Nice
Alex Gaynor
 
PPTX
Django Framework Overview forNon-Python Developers
Rosario Renga
 
ODP
Desenvolvimento web simples com Python e DJango
Rafael Nunes
 
PDF
Synthesis and targetting of mitochondrial proteins
Ajay Badyal
 
ZIP
Python e Django na Globo.com
ricobl
 
Edte 314 presentation week 3
Jess Hall
 
Extending WordPress' TinyMCE
Hristo Chakarov
 
Finding and understanding patterns in distant reading.
Ted Underwood
 
Trend journal 1 the space age resurfaces
Aidenn Mullen
 
Busi 710 final slidedeck
Aidenn Mullen
 
Design thinking project plan draft for Apex
Aidenn Mullen
 
Contextual Research design brief
Aidenn Mullen
 
Ethnographic research final - graduate design management
Aidenn Mullen
 
Making Django and NoSQL Play Nice
Alex Gaynor
 
Django Framework Overview forNon-Python Developers
Rosario Renga
 
Desenvolvimento web simples com Python e DJango
Rafael Nunes
 
Synthesis and targetting of mitochondrial proteins
Ajay Badyal
 
Python e Django na Globo.com
ricobl
 
Ad

Similar to Why Django for Web Development (20)

PDF
Django
sisibeibei
 
PDF
Django Workflow and Architecture
Andolasoft Inc
 
PPTX
Introduction to Django
Ahmed Salama
 
PPTX
Web development with django - Basics Presentation
Shrinath Shenoy
 
PDF
Web development django.pdf
KomalSaini178773
 
PDF
Introduction to django
Ilian Iliev
 
PPTX
Basic Python Django
Kaleem Ullah Mangrio
 
DOCX
Akash rajguru project report sem v
Akash Rajguru
 
PDF
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
 
PPTX
The Django Web Application Framework 2
fishwarter
 
PPTX
Django course
Nagi Annapureddy
 
PPTX
Django Architecture Introduction
Haiqi Chen
 
PPTX
The Django Web Application Framework 2
fishwarter
 
PPTX
The Django Web Application Framework 2
fishwarter
 
PPT
Mini Curso Django Ii Congresso Academico Ces
Leonardo Fernandes
 
PPT
DJango
Sunil OS
 
PPTX
Introduction to django
Vlad Voskoboynik
 
PPTX
Django Framework Interview Question and Answer partOne.pptx
Md. Naimur Rahman
 
PDF
Mini Curso de Django
Felipe Queiroz
 
Django
sisibeibei
 
Django Workflow and Architecture
Andolasoft Inc
 
Introduction to Django
Ahmed Salama
 
Web development with django - Basics Presentation
Shrinath Shenoy
 
Web development django.pdf
KomalSaini178773
 
Introduction to django
Ilian Iliev
 
Basic Python Django
Kaleem Ullah Mangrio
 
Akash rajguru project report sem v
Akash Rajguru
 
GDG Addis - An Introduction to Django and App Engine
Yared Ayalew
 
The Django Web Application Framework 2
fishwarter
 
Django course
Nagi Annapureddy
 
Django Architecture Introduction
Haiqi Chen
 
The Django Web Application Framework 2
fishwarter
 
The Django Web Application Framework 2
fishwarter
 
Mini Curso Django Ii Congresso Academico Ces
Leonardo Fernandes
 
DJango
Sunil OS
 
Introduction to django
Vlad Voskoboynik
 
Django Framework Interview Question and Answer partOne.pptx
Md. Naimur Rahman
 
Mini Curso de Django
Felipe Queiroz
 
Ad

Recently uploaded (20)

PDF
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PPTX
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PPTX
Difference between write and update in odoo 18
Celine George
 
AI-Powered-Visual-Storytelling-for-Nonprofits.pdf
TechSoup
 
Introduction presentation of the patentbutler tool
MIPLM
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
HUMAN RESOURCE MANAGEMENT: RECRUITMENT, SELECTION, PLACEMENT, DEPLOYMENT, TRA...
PRADEEP ABOTHU
 
infertility, types,causes, impact, and management
Ritu480198
 
Difference between write and update in odoo 18
Celine George
 

Why Django for Web Development

  • 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