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

MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
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
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
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
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
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
 
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
 
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
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
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
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 

Recently uploaded (20)

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
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
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
 
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
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
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)
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
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
 
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
 
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
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
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...
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.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