SlideShare a Scribd company logo
1 of 30
Download to read offline
Python Web Framework
2
Django?
3
Django?
4
Django
 A high-level Python web framework
 Created in 2003, open sourced in 2005
 Encourages rapid development and clean, pragmatic design
 Widely supported, many deployment options
 Focus on automation and DRY
 “For perfectionists with deadlines”
 MVC (MTV) Architecture
5
Who uses Django?
 BitBucket
 DISQUS (serving 400 million people)
 Pinterest
 Instagram
 dPaste
 Mozilla (support.mozill, addons.mozilla)
 NASA
 PBS (Public Broadcasting Service)
 The Washington Post, NY Times, LA Times, The Guardian
 National Geographic, Discovery Channel
6
Features
 Object Relational Mapper - ORM
 Template System
 customizable Admin Interface, makes CRUD easy
 Built-in light weight Web Server
 URL design
 Authentication / Authorization
 Internationalization support
 Cache framework, with multiple cache mechanisms
 Free, and Great Documentation
MVC vs. MTV
M
Model
V
View
C
Controller
M
Model
T
Template
V
View
8
Installation
 Prerequisites
 Python
 PIP for installing Python packages
 pip install Django
 pip install mysql-python
 Testing installation
 import django
 Create a requirements.txt
 $ pip install -r requirements.txt
9
Virtualenv
 pip “one project, one virtualenv”
 projects with different dependencies, package versions
 easier to deploy. Forget dependency hell!
10
Django Architecture
Models Describes your data
Views Controls what users sees
Templates How user sees it
Controller URL dispatcher
DataBase
Model
View
Template URL dispatcher
Brower
11
Project Creation
 Creating new Project
 django-admin.py startproject demoproject
A project is a collection of applications
 Creating new Application
 python manage.py startapp demosite
An application tries to provide a single, relatively self-contained set of related functions
 Using the built-in web server
 python manage.py runserver
Runs by default at port 8000
12
Project Directory Structure
demosite/
manage.py.
demosite/
__init__.py
settings.py
urls.py
wsgi.py
templates/
static/
demoapp/
__init__.py
urls.py
views.py
models.py
admin.py
forms.py
13
Apps
 use short, obvious, single-word names for your apps
 many small apps is better than a few giant apps:
 explain an app in a sentence. If you can't, split the app
 rather than expand an app, write a new app
 don't reinvent the wheel!
 django.contrib
 3rd-party apps
14
Settings
 use - multiple settings files: - per environment:
 dev, testing, staging, production - per developer (local settings)
 all settings files must inherit from base, so you can do:
 INSTALLED_APPS += ('debug_toolbar', ) - version control all the settings!
15
Models
you can use Django without a database
Or
describe your database layout in Python code with django ORM
16
Models
from django.db import models
class Reporter(models.Model):
full_name = models.CharField(max_length=70)
def __str__(self): # __unicode__ on Python 2
return self.full_name
class Article(models.Model):
pub_date = models.DateField()
headline = models.CharField(max_length=200)
content = models.TextField() reporter = models.ForeignKey(Reporter)
def __str__(self): # __unicode__ on Python 2
return self.headline
17
admin
from django.contrib import admin
from . import models
admin.site.register(models.Article)
18
URLs
 Map URLs in requests to code that can be executed
 Regular expressions!
 Subsections of your site can have their own urls.py modules
19
URLs
 Root URL should be configured in settings.py
o ROOT_URLCONF = 'app.urls'
 Example
urlpatterns = patterns(' ',
(r'^articles-year/$', 'mysite.news.views.articles_year'),
)
20
Views
 Map Code that handles requests
 Other frameworks often call these “controllers”
 Basically a function that:
 gets a request
 returns text or a response
21
Views
from django.shortcuts import render
from .models import Article
def year_archive(request, year):
a_list = Article.objects.filter(pub_date__year=year)
context = {'year': year, 'article_list': a_list}
return render(request, 'news/year_archive.html', context)
22
Django Template Language
 Call a function or do logic:
{% ... %}
 Variable substitution:
{{ bar }}
 Filters:
{{ foo|bar }}
23
Django Template Language
{% extends "base.html" %}
{% block title %}Articles for {{ year }}{% endblock %}
{% block content %}
<h1>Articles for {{ year }}</h1>
{% for article in article_list %}
<p>{{ article.headline }}</p>
<p>By {{ article.reporter.full_name }}</p>
<p>Published {{ article.pub_date|date:"F j, Y" }}</p>
{% endfor %}
{% endblock %}
24
Django Template Language (base)
{% load staticfiles %}
<html>
<head>
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<img src="{% static "images/sitelogo.png" %}" alt="Logo" />
{% block content %}{% endblock %}
</body>
</html>
25
Form
from django import forms
class MyForm(forms.Form):
name = forms.CharField(max_length=30)
email = forms.EmailField()
26
Using a Form in a View
from myapp.forms import MyForm
def my_view(request):
form = MyForm(request.POST or None)
if request.method == "POST" and form.is_valid():
name = form.cleaned_data['name']
email = form.cleaned_data['email']
# do something great with that data
return render(request, 'myapp/myform.html', { 'form': form })
27
Forms in Templates
<html>
...
<body>
<form action="{% url 'myapp:my_form' %}" method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Go!</button>
</form>
</body>
</html>
28
Django-rest-framework
Django REST framework is a powerful and flexible toolkit for building Web APIs.
29
Django-rest-framework (installation)
 pip install djangorestframework
 pip install django-rest-swagger
 Pip install django-filter
30
Django-rest-framework (installation)
# settings.py
INSTALLED_APPS = (
...
‘rest_framework’,
)

More Related Content

What's hot

Web application development with Django framework
Web application development with Django frameworkWeb application development with Django framework
Web application development with Django frameworkflapiello
 
Config/BuildConfig
Config/BuildConfigConfig/BuildConfig
Config/BuildConfigVijay Shukla
 
Dicoding Developer Coaching #30: Android | Mengenal Macam-Macam Software Desi...
Dicoding Developer Coaching #30: Android | Mengenal Macam-Macam Software Desi...Dicoding Developer Coaching #30: Android | Mengenal Macam-Macam Software Desi...
Dicoding Developer Coaching #30: Android | Mengenal Macam-Macam Software Desi...DicodingEvent
 
Web development with django - Basics Presentation
Web development with django - Basics PresentationWeb development with django - Basics Presentation
Web development with django - Basics PresentationShrinath Shenoy
 
Django app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh AgarwalDjango app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh Agarwalratneshsinghparihar
 
Introduction to CodeIgniter
Introduction to CodeIgniterIntroduction to CodeIgniter
Introduction to CodeIgniterPiti Suwannakom
 
Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practiceseleksdev
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introductionCommit University
 
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...DicodingEvent
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniterAhmad Arif
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksmwbrooks
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for BeginnersJason Davies
 
Skroutz Android MVP and Adapter Delegates presentation
Skroutz Android MVP and Adapter Delegates  presentationSkroutz Android MVP and Adapter Delegates  presentation
Skroutz Android MVP and Adapter Delegates presentationgmetal
 

What's hot (17)

Web application development with Django framework
Web application development with Django frameworkWeb application development with Django framework
Web application development with Django framework
 
Config/BuildConfig
Config/BuildConfigConfig/BuildConfig
Config/BuildConfig
 
dJango
dJangodJango
dJango
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
Dicoding Developer Coaching #30: Android | Mengenal Macam-Macam Software Desi...
Dicoding Developer Coaching #30: Android | Mengenal Macam-Macam Software Desi...Dicoding Developer Coaching #30: Android | Mengenal Macam-Macam Software Desi...
Dicoding Developer Coaching #30: Android | Mengenal Macam-Macam Software Desi...
 
Web development with django - Basics Presentation
Web development with django - Basics PresentationWeb development with django - Basics Presentation
Web development with django - Basics Presentation
 
CodeIgniter 101 Tutorial
CodeIgniter 101 TutorialCodeIgniter 101 Tutorial
CodeIgniter 101 Tutorial
 
Django app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh AgarwalDjango app deployment in Azure By Saurabh Agarwal
Django app deployment in Azure By Saurabh Agarwal
 
Introduction to CodeIgniter
Introduction to CodeIgniterIntroduction to CodeIgniter
Introduction to CodeIgniter
 
CakePHP: An Introduction
CakePHP: An IntroductionCakePHP: An Introduction
CakePHP: An Introduction
 
Lecture android best practices
Lecture   android best practicesLecture   android best practices
Lecture android best practices
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introduction
 
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniter
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
Skroutz Android MVP and Adapter Delegates presentation
Skroutz Android MVP and Adapter Delegates  presentationSkroutz Android MVP and Adapter Delegates  presentation
Skroutz Android MVP and Adapter Delegates presentation
 

Viewers also liked

TCI 2015 Industry Clusters and Entrepreneurial Ecosystems: Competing Agendas ...
TCI 2015 Industry Clusters and Entrepreneurial Ecosystems: Competing Agendas ...TCI 2015 Industry Clusters and Entrepreneurial Ecosystems: Competing Agendas ...
TCI 2015 Industry Clusters and Entrepreneurial Ecosystems: Competing Agendas ...TCI Network
 
Service oriented architecture
Service oriented architectureService oriented architecture
Service oriented architectureMahdi Nasseri
 
05 business model patterns
05 business model patterns05 business model patterns
05 business model patternsMahdi Nasseri
 
سرمایه گذاری جسورانه Venture Capital (با نگاهی به بازار مالی و سرمایه گذاری د...
سرمایه گذاری جسورانه Venture Capital (با نگاهی به بازار مالی و سرمایه گذاری د...سرمایه گذاری جسورانه Venture Capital (با نگاهی به بازار مالی و سرمایه گذاری د...
سرمایه گذاری جسورانه Venture Capital (با نگاهی به بازار مالی و سرمایه گذاری د...Abouzar Najmi
 
I love you slideshare
I love you slideshareI love you slideshare
I love you slideshareMahdi Nasseri
 
12 reasons to promote entrepreneurship in iran
12 reasons to promote entrepreneurship in iran12 reasons to promote entrepreneurship in iran
12 reasons to promote entrepreneurship in iranMahdi Nasseri
 
بوم مدل کسب و کار
بوم مدل کسب و کاربوم مدل کسب و کار
بوم مدل کسب و کارArman Safayi
 
و مدل کسب‌وکارشUber استارتاپ
 و مدل کسب‌وکارشUber استارتاپ و مدل کسب‌وکارشUber استارتاپ
و مدل کسب‌وکارشUber استارتاپArman Safayi
 
Money making techniques
Money making techniquesMoney making techniques
Money making techniquesMahdi Nasseri
 
استارتاپ ویکند چیست؟
استارتاپ ویکند چیست؟استارتاپ ویکند چیست؟
استارتاپ ویکند چیست؟Pouya Kondori
 
06 Business Model development
06 Business Model development06 Business Model development
06 Business Model developmentMahdi Nasseri
 
هفت گام اولیه برای استارتاپ ها به همراه معرفی ابزارها و روش ها
هفت گام اولیه برای استارتاپ ها به همراه معرفی ابزارها و روش هاهفت گام اولیه برای استارتاپ ها به همراه معرفی ابزارها و روش ها
هفت گام اولیه برای استارتاپ ها به همراه معرفی ابزارها و روش هاMahdi Nasseri
 
Buyer decision making model (by @mahdinasseri)
Buyer decision making model (by @mahdinasseri)Buyer decision making model (by @mahdinasseri)
Buyer decision making model (by @mahdinasseri)Mahdi Nasseri
 
Content mapping template
Content mapping templateContent mapping template
Content mapping templateMahdi Nasseri
 
مسیر حرفه‌ای؛ راهبردهایی برای پیشرفت شغلی
مسیر حرفه‌ای؛ راهبردهایی برای پیشرفت شغلیمسیر حرفه‌ای؛ راهبردهایی برای پیشرفت شغلی
مسیر حرفه‌ای؛ راهبردهایی برای پیشرفت شغلیMahdi Nasseri
 
اولین استارتاپ ویکند سبز تهران
اولین استارتاپ ویکند سبز تهراناولین استارتاپ ویکند سبز تهران
اولین استارتاپ ویکند سبز تهرانsarvenaz arianfar
 
Startupweekend workshops
Startupweekend workshopsStartupweekend workshops
Startupweekend workshopsMahdi Nasseri
 
How to validate(hamfekr)
How to validate(hamfekr)How to validate(hamfekr)
How to validate(hamfekr)Mehdi Rahmani
 

Viewers also liked (20)

TCI 2015 Industry Clusters and Entrepreneurial Ecosystems: Competing Agendas ...
TCI 2015 Industry Clusters and Entrepreneurial Ecosystems: Competing Agendas ...TCI 2015 Industry Clusters and Entrepreneurial Ecosystems: Competing Agendas ...
TCI 2015 Industry Clusters and Entrepreneurial Ecosystems: Competing Agendas ...
 
Service oriented architecture
Service oriented architectureService oriented architecture
Service oriented architecture
 
05 business model patterns
05 business model patterns05 business model patterns
05 business model patterns
 
سرمایه گذاری جسورانه Venture Capital (با نگاهی به بازار مالی و سرمایه گذاری د...
سرمایه گذاری جسورانه Venture Capital (با نگاهی به بازار مالی و سرمایه گذاری د...سرمایه گذاری جسورانه Venture Capital (با نگاهی به بازار مالی و سرمایه گذاری د...
سرمایه گذاری جسورانه Venture Capital (با نگاهی به بازار مالی و سرمایه گذاری د...
 
07 customer insight
07 customer insight07 customer insight
07 customer insight
 
I love you slideshare
I love you slideshareI love you slideshare
I love you slideshare
 
12 reasons to promote entrepreneurship in iran
12 reasons to promote entrepreneurship in iran12 reasons to promote entrepreneurship in iran
12 reasons to promote entrepreneurship in iran
 
بوم مدل کسب و کار
بوم مدل کسب و کاربوم مدل کسب و کار
بوم مدل کسب و کار
 
و مدل کسب‌وکارشUber استارتاپ
 و مدل کسب‌وکارشUber استارتاپ و مدل کسب‌وکارشUber استارتاپ
و مدل کسب‌وکارشUber استارتاپ
 
Money making techniques
Money making techniquesMoney making techniques
Money making techniques
 
استارتاپ ویکند چیست؟
استارتاپ ویکند چیست؟استارتاپ ویکند چیست؟
استارتاپ ویکند چیست؟
 
e-commerce
e-commercee-commerce
e-commerce
 
06 Business Model development
06 Business Model development06 Business Model development
06 Business Model development
 
هفت گام اولیه برای استارتاپ ها به همراه معرفی ابزارها و روش ها
هفت گام اولیه برای استارتاپ ها به همراه معرفی ابزارها و روش هاهفت گام اولیه برای استارتاپ ها به همراه معرفی ابزارها و روش ها
هفت گام اولیه برای استارتاپ ها به همراه معرفی ابزارها و روش ها
 
Buyer decision making model (by @mahdinasseri)
Buyer decision making model (by @mahdinasseri)Buyer decision making model (by @mahdinasseri)
Buyer decision making model (by @mahdinasseri)
 
Content mapping template
Content mapping templateContent mapping template
Content mapping template
 
مسیر حرفه‌ای؛ راهبردهایی برای پیشرفت شغلی
مسیر حرفه‌ای؛ راهبردهایی برای پیشرفت شغلیمسیر حرفه‌ای؛ راهبردهایی برای پیشرفت شغلی
مسیر حرفه‌ای؛ راهبردهایی برای پیشرفت شغلی
 
اولین استارتاپ ویکند سبز تهران
اولین استارتاپ ویکند سبز تهراناولین استارتاپ ویکند سبز تهران
اولین استارتاپ ویکند سبز تهران
 
Startupweekend workshops
Startupweekend workshopsStartupweekend workshops
Startupweekend workshops
 
How to validate(hamfekr)
How to validate(hamfekr)How to validate(hamfekr)
How to validate(hamfekr)
 

Similar to بررسی چارچوب جنگو

Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture IntroductionHaiqi Chen
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web FrameworkDavid Gibbons
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030Kevin Wu
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!David Gibbons
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docxfantabulous2024
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Tony Frame
 
Akash rajguru project report sem v
Akash rajguru project report sem vAkash rajguru project report sem v
Akash rajguru project report sem vAkash Rajguru
 
SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015Pushkar Chivate
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with PythonBrian Lyttle
 
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
 
Django framework
Django framework Django framework
Django framework TIB Academy
 
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
 
Django 1.10.3 Getting started
Django 1.10.3 Getting startedDjango 1.10.3 Getting started
Django 1.10.3 Getting startedMoniaJ
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django IntroductionGanga Ram
 
Django Workflow and Architecture
Django Workflow and ArchitectureDjango Workflow and Architecture
Django Workflow and ArchitectureAndolasoft Inc
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| EdurekaEdureka!
 

Similar to بررسی چارچوب جنگو (20)

Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
An Introduction to Django Web Framework
An Introduction to Django Web FrameworkAn Introduction to Django Web Framework
An Introduction to Django Web Framework
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030
 
Django
DjangoDjango
Django
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 
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
 
SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
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)
 
Django framework
Django framework Django framework
Django 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
 
Pyramid patterns
Pyramid patternsPyramid patterns
Pyramid patterns
 
Django 1.10.3 Getting started
Django 1.10.3 Getting startedDjango 1.10.3 Getting started
Django 1.10.3 Getting started
 
A Basic Django Introduction
A Basic Django IntroductionA Basic Django Introduction
A Basic Django Introduction
 
Django - basics
Django - basicsDjango - basics
Django - basics
 
Django Workflow and Architecture
Django Workflow and ArchitectureDjango Workflow and Architecture
Django Workflow and Architecture
 
Django interview Questions| Edureka
Django interview  Questions| EdurekaDjango interview  Questions| Edureka
Django interview Questions| Edureka
 

Recently uploaded

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Recently uploaded (20)

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 

بررسی چارچوب جنگو

  • 4. 4 Django  A high-level Python web framework  Created in 2003, open sourced in 2005  Encourages rapid development and clean, pragmatic design  Widely supported, many deployment options  Focus on automation and DRY  “For perfectionists with deadlines”  MVC (MTV) Architecture
  • 5. 5 Who uses Django?  BitBucket  DISQUS (serving 400 million people)  Pinterest  Instagram  dPaste  Mozilla (support.mozill, addons.mozilla)  NASA  PBS (Public Broadcasting Service)  The Washington Post, NY Times, LA Times, The Guardian  National Geographic, Discovery Channel
  • 6. 6 Features  Object Relational Mapper - ORM  Template System  customizable Admin Interface, makes CRUD easy  Built-in light weight Web Server  URL design  Authentication / Authorization  Internationalization support  Cache framework, with multiple cache mechanisms  Free, and Great Documentation
  • 8. 8 Installation  Prerequisites  Python  PIP for installing Python packages  pip install Django  pip install mysql-python  Testing installation  import django  Create a requirements.txt  $ pip install -r requirements.txt
  • 9. 9 Virtualenv  pip “one project, one virtualenv”  projects with different dependencies, package versions  easier to deploy. Forget dependency hell!
  • 10. 10 Django Architecture Models Describes your data Views Controls what users sees Templates How user sees it Controller URL dispatcher DataBase Model View Template URL dispatcher Brower
  • 11. 11 Project Creation  Creating new Project  django-admin.py startproject demoproject A project is a collection of applications  Creating new Application  python manage.py startapp demosite An application tries to provide a single, relatively self-contained set of related functions  Using the built-in web server  python manage.py runserver Runs by default at port 8000
  • 13. 13 Apps  use short, obvious, single-word names for your apps  many small apps is better than a few giant apps:  explain an app in a sentence. If you can't, split the app  rather than expand an app, write a new app  don't reinvent the wheel!  django.contrib  3rd-party apps
  • 14. 14 Settings  use - multiple settings files: - per environment:  dev, testing, staging, production - per developer (local settings)  all settings files must inherit from base, so you can do:  INSTALLED_APPS += ('debug_toolbar', ) - version control all the settings!
  • 15. 15 Models you can use Django without a database Or describe your database layout in Python code with django ORM
  • 16. 16 Models from django.db import models class Reporter(models.Model): full_name = models.CharField(max_length=70) def __str__(self): # __unicode__ on Python 2 return self.full_name class Article(models.Model): pub_date = models.DateField() headline = models.CharField(max_length=200) content = models.TextField() reporter = models.ForeignKey(Reporter) def __str__(self): # __unicode__ on Python 2 return self.headline
  • 17. 17 admin from django.contrib import admin from . import models admin.site.register(models.Article)
  • 18. 18 URLs  Map URLs in requests to code that can be executed  Regular expressions!  Subsections of your site can have their own urls.py modules
  • 19. 19 URLs  Root URL should be configured in settings.py o ROOT_URLCONF = 'app.urls'  Example urlpatterns = patterns(' ', (r'^articles-year/$', 'mysite.news.views.articles_year'), )
  • 20. 20 Views  Map Code that handles requests  Other frameworks often call these “controllers”  Basically a function that:  gets a request  returns text or a response
  • 21. 21 Views from django.shortcuts import render from .models import Article def year_archive(request, year): a_list = Article.objects.filter(pub_date__year=year) context = {'year': year, 'article_list': a_list} return render(request, 'news/year_archive.html', context)
  • 22. 22 Django Template Language  Call a function or do logic: {% ... %}  Variable substitution: {{ bar }}  Filters: {{ foo|bar }}
  • 23. 23 Django Template Language {% extends "base.html" %} {% block title %}Articles for {{ year }}{% endblock %} {% block content %} <h1>Articles for {{ year }}</h1> {% for article in article_list %} <p>{{ article.headline }}</p> <p>By {{ article.reporter.full_name }}</p> <p>Published {{ article.pub_date|date:"F j, Y" }}</p> {% endfor %} {% endblock %}
  • 24. 24 Django Template Language (base) {% load staticfiles %} <html> <head> <title>{% block title %}{% endblock %}</title> </head> <body> <img src="{% static "images/sitelogo.png" %}" alt="Logo" /> {% block content %}{% endblock %} </body> </html>
  • 25. 25 Form from django import forms class MyForm(forms.Form): name = forms.CharField(max_length=30) email = forms.EmailField()
  • 26. 26 Using a Form in a View from myapp.forms import MyForm def my_view(request): form = MyForm(request.POST or None) if request.method == "POST" and form.is_valid(): name = form.cleaned_data['name'] email = form.cleaned_data['email'] # do something great with that data return render(request, 'myapp/myform.html', { 'form': form })
  • 27. 27 Forms in Templates <html> ... <body> <form action="{% url 'myapp:my_form' %}" method="post"> {% csrf_token %} {{ form.as_p }} <button type="submit">Go!</button> </form> </body> </html>
  • 28. 28 Django-rest-framework Django REST framework is a powerful and flexible toolkit for building Web APIs.
  • 29. 29 Django-rest-framework (installation)  pip install djangorestframework  pip install django-rest-swagger  Pip install django-filter