SlideShare una empresa de Scribd logo
1 de 44
Descargar para leer sin conexión
Django
Beyond Basics
Who is this for?
NOOB GOOD CHUCKNORRIS
What I thought…

NOOB GOOD CHUCKNORRIS
It is more like…
DESIGNER
BIG PICTUREGUY OPERATIONS
ADMIN
RAILS GUY
@arocks
arunrocks.com
Hi!
Disclaimer
This presentationdoesnot aim tobe a
comprehensiveoverviewof any part of Django.
Thereare severaltutorialscoveringvarious
aspectsof theframework. Insteadthisis talkis
part experiencesharing,part advocacyand
part entertainment.
What is Django?
It is just a framework!
Definitely not a CMS!
Get the BIG picture
The BIG picture slide
Thanks to Karen Rustad& Asheesh Laroia
Also starring…
• Lightweight,standaloneweb serverfor dev
• Formserializationand validationsystem
• Flexiblecachingframework
• Supportfor middlewareclasses atvariouslevels
• Internationalizationsystem
• Unit testframework
Why is Django Awesome?
List of awesome-ness
• Admin
• Security
• Greatdocumentation
• Friendlycommunity
• Stable
• Batteriesincluded
• OpenSource!
Comingfrom PHP/ASP
background
Coming from PHP/ASPbackground
Step 1: ForgetEverything,esphow easylife was…
Step 2:Thinkarchitecturefirst
Step3:ThinkaboutSeparationof Concerns
Step 4:???
Step 5: Profit!!!
101bad excuses not touse Django
But Django is too heavy!
Flask
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
Djangoexampleis onefile& almostthesame size!
Django
from django.http import HttpResponse
from django.conf.urls.defaults import patterns
DEBUG=True
ROOT_URLCONF = 'pico'
DATABASES = { 'default': {} }
SECRET_KEY = '0123456789‘ * 50
def index(request):
return HttpResponse('Hello World!')
urlpatterns = patterns('', (r'^$', index))
$ PYTHONPATH=. django-admin.py runserver
0.0.0.0:8000 --settings=pico
No,
It is batteries included!
(+ cool downloadable apps)
But Django is too ugly!
Why use:
“example.com/product/[0-9]+”
?
Isn’t this is much cooler:
“example.com/product/{id}”
? 
SQL Injection!
example.com/product/1 or 1=1
will become:
SELECT * FROM Products WHERE ID = 1 OR 1=1
EvenDjango will not always save you:
“example.com/product/(.+)”
Avoid!
Be as strict as possible:
“example.com/product/[0-9]+”
Looksprettier now, huh?
Why not Django?
• Unusually highperformanceneeds
• ExistingDatabase models?
• Migrations?
• ORM/Templateisnot enough
Inotherwords,youwantto replaceall of Django’s
components.Whichyou would eventually?!
Best Practices
• Distrust outsidedata. Sanitizeeverything!
• Don’tleakimplementationdetails.
• FatterModels/Managersand LeanerViews
• FollowPEP8and readable names
• Be asDRY as possible.
• Breakdown intoreusable Apps
novice questions
What is a QuerySet?
Why is media separate?
Which IDE?
How to deploy?
Must-learn Python Packages
Must-learn Python Packages
• Pip – Don’tstart withoutthis!
• iPython/BPython– Betterthanvanillaconsole
• Pudb– Bestdebugger
• Fabric– Easydeployment
But what goes well with Django?
Must-learn Django Packages
Must-learn Django Packages
• Django-debug-toolbar– Only inDEV!
• Django_compressor– Notjust compression
• Django-extensions– Tonsof goodies
• South– Gettingintegrated?
• Celery– DelayedGratification
• Tastypie*–Build yummy APIs
* Or anything that suits you
Other cool Django Packages
• Djangosocialauth:One app to most Social logins
• DjangoPaypal:PayPal Payments Standard & Pro
• crispy-forms:NiceHTML for forms
• django-taggit:Implement tags easily
• Psycopg2: Talk to PostgreSQL, a solid database
• django-storages:Store anywhere - Cloud, DB or FTP
My Django Workflow
1) Create a new Django project
2) Find a3rd party app or create anapp
3) Write/Improve models.py
4) Play with queries onconsole. Run syncdb.
5) Add abare admin.py
6) Add data from admin UI
7) Write views.py. Leverage CBVs
8) If needed, adda model form to forms.py
9) Add views to urls.py
10) Jump to step 3till app looks good
11) jump to step 2
For examples, head to arunrocks.com
A simplistic Django workflow…
1) Create a new Django project
2) Find a3rd party app or create an app
3) Write/Improve models.py
4) Play with queries onconsole. Repeat step 3
5) Add abare admin.py
6) Add data from admin UI
7) Write views.py. Leverage CBVs
8) If needed, adda model form to forms.py
9) Add views to urls.py
10) Jump to step 3till app looks good
Make friends with Git, South, Fabric…
A better Django workflow…
$ ./manage.py schemamigration app --initial
$ ./manage.py migrate app
$ ./manage.py schemamigration app --auto
$ git init
Write tests.py
Fabric/Puppet/Chef
Forms are easy!
Forms are easy!
• Use formsas much as possible(Hint:security)
• ModelFormscovermost uses case
• Butselect whichfields showin ModelForms
• Hard set all defaults beforeform.save
• FormViewis a greatgenericviewfor forms
• Usingbootstrap?Use crispy-formsto savetime
Should I use CBVs?
Ok, I made a Django
site. Now what?
Ok, I made a Django site. Now what?
• Turn off DEBUG
• Use HTTPS logins
• Set X-Frame-
Optionsheader
• Use SESSION_COOKIE_
SECURE
• Change /admin/ url Oreasier,go to
http://ponycheckup.com/
@arocks

Más contenido relacionado

La actualidad más candente

AzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр ШевнинAzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр ШевнинJSC “Arcadia Inc”
 
Android application architecture
Android application architectureAndroid application architecture
Android application architectureRomain Rochegude
 
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoDjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoCasey Kinsey
 
Test Automation Framework using Cucumber BDD Overview - part 2
Test Automation Framework using Cucumber BDD Overview - part 2Test Automation Framework using Cucumber BDD Overview - part 2
Test Automation Framework using Cucumber BDD Overview - part 2Mindfire Solutions
 
Creating Gradle Plugins
Creating Gradle PluginsCreating Gradle Plugins
Creating Gradle PluginsAnnyce Davis
 
Develop Maintainable Apps
Develop Maintainable AppsDevelop Maintainable Apps
Develop Maintainable AppsAnnyce Davis
 
[Srijan Wednesday Webinars] Choosing the Right Testing Framework
[Srijan Wednesday Webinars] Choosing the Right Testing Framework[Srijan Wednesday Webinars] Choosing the Right Testing Framework
[Srijan Wednesday Webinars] Choosing the Right Testing FrameworkSrijan Technologies
 
[Android] DI in multimodule application
[Android] DI in multimodule application[Android] DI in multimodule application
[Android] DI in multimodule applicationOleg Mazhukin
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Mindfire Solutions
 
Testing nightwatch, by David Torroija
Testing nightwatch, by David TorroijaTesting nightwatch, by David Torroija
Testing nightwatch, by David TorroijaDavid Torroija
 
Protractor end-to-end testing framework for angular js
Protractor   end-to-end testing framework for angular jsProtractor   end-to-end testing framework for angular js
Protractor end-to-end testing framework for angular jscodeandyou forums
 
Unit testing @ WordPress Meetup Tilburg 7 januari 2014
Unit testing @ WordPress Meetup Tilburg 7 januari 2014Unit testing @ WordPress Meetup Tilburg 7 januari 2014
Unit testing @ WordPress Meetup Tilburg 7 januari 2014Barry Kooij
 
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...TestingAR Meetup
 

La actualidad más candente (20)

Dagger2 Intro
Dagger2 IntroDagger2 Intro
Dagger2 Intro
 
AzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр ШевнинAzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
AzovDevMeetup 2016 | Angular 2: обзор | Александр Шевнин
 
Android application architecture
Android application architectureAndroid application architecture
Android application architecture
 
Workshop - E2e tests with protractor
Workshop - E2e tests with protractorWorkshop - E2e tests with protractor
Workshop - E2e tests with protractor
 
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in DjangoDjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
DjangoCon 2013 - How to Write Fast and Efficient Unit Tests in Django
 
Test Automation Framework using Cucumber BDD Overview - part 2
Test Automation Framework using Cucumber BDD Overview - part 2Test Automation Framework using Cucumber BDD Overview - part 2
Test Automation Framework using Cucumber BDD Overview - part 2
 
Automated UI Testing
Automated UI TestingAutomated UI Testing
Automated UI Testing
 
Dagger 2
Dagger 2Dagger 2
Dagger 2
 
Creating Gradle Plugins
Creating Gradle PluginsCreating Gradle Plugins
Creating Gradle Plugins
 
Develop Maintainable Apps
Develop Maintainable AppsDevelop Maintainable Apps
Develop Maintainable Apps
 
[Srijan Wednesday Webinars] Choosing the Right Testing Framework
[Srijan Wednesday Webinars] Choosing the Right Testing Framework[Srijan Wednesday Webinars] Choosing the Right Testing Framework
[Srijan Wednesday Webinars] Choosing the Right Testing Framework
 
[Android] DI in multimodule application
[Android] DI in multimodule application[Android] DI in multimodule application
[Android] DI in multimodule application
 
Marcin Wasilczyk - Page objects with selenium
Marcin Wasilczyk - Page objects with seleniumMarcin Wasilczyk - Page objects with selenium
Marcin Wasilczyk - Page objects with selenium
 
Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)Test Automation Framework using Cucumber BDD overview (part 1)
Test Automation Framework using Cucumber BDD overview (part 1)
 
Testing nightwatch, by David Torroija
Testing nightwatch, by David TorroijaTesting nightwatch, by David Torroija
Testing nightwatch, by David Torroija
 
Protractor
Protractor Protractor
Protractor
 
Protractor end-to-end testing framework for angular js
Protractor   end-to-end testing framework for angular jsProtractor   end-to-end testing framework for angular js
Protractor end-to-end testing framework for angular js
 
Unit testing @ WordPress Meetup Tilburg 7 januari 2014
Unit testing @ WordPress Meetup Tilburg 7 januari 2014Unit testing @ WordPress Meetup Tilburg 7 januari 2014
Unit testing @ WordPress Meetup Tilburg 7 januari 2014
 
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
TestingAR XX - Protractor e2e Test Framework - Introduction what we have lear...
 
Cypress workshop for JSFoo 2019
Cypress  workshop for JSFoo 2019Cypress  workshop for JSFoo 2019
Cypress workshop for JSFoo 2019
 

Similar a Django Beyond Basics Guide

Move out from AppEngine, and Python PaaS alternatives
Move out from AppEngine, and Python PaaS alternativesMove out from AppEngine, and Python PaaS alternatives
Move out from AppEngine, and Python PaaS alternativestzang ms
 
Django getting start
Django getting startDjango getting start
Django getting startshengwu83
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in DjangoLakshman Prasad
 
How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015hirokiky
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersRosario Renga
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Waysmalltown
 
Netflix oss season 2 episode 1 - meetup Lightning talks
Netflix oss   season 2 episode 1 - meetup Lightning talksNetflix oss   season 2 episode 1 - meetup Lightning talks
Netflix oss season 2 episode 1 - meetup Lightning talksRuslan Meshenberg
 
10 things you should know about django
10 things you should know about django10 things you should know about django
10 things you should know about djangoAdieu
 
Django Article V0
Django Article V0Django Article V0
Django Article V0Udi Bauman
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGuillaume Laforge
 
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?Dmitri Shiryaev
 
python full stack course in hyderabad...
python full stack course in hyderabad...python full stack course in hyderabad...
python full stack course in hyderabad...sowmyavibhin
 
python full stack course in hyderabad...
python full stack course in hyderabad...python full stack course in hyderabad...
python full stack course in hyderabad...sowmyavibhin
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django ArchitectureRami Sayar
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-wayRobert Lujo
 

Similar a Django Beyond Basics Guide (20)

Introduce Django
Introduce DjangoIntroduce Django
Introduce Django
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
 
Django
DjangoDjango
Django
 
Move out from AppEngine, and Python PaaS alternatives
Move out from AppEngine, and Python PaaS alternativesMove out from AppEngine, and Python PaaS alternatives
Move out from AppEngine, and Python PaaS alternatives
 
Django getting start
Django getting startDjango getting start
Django getting start
 
django
djangodjango
django
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in Django
 
How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015How we realized SOA by Python at PyCon JP 2015
How we realized SOA by Python at PyCon JP 2015
 
Django Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python DevelopersDjango Framework Overview forNon-Python Developers
Django Framework Overview forNon-Python Developers
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
 
Netflix oss season 2 episode 1 - meetup Lightning talks
Netflix oss   season 2 episode 1 - meetup Lightning talksNetflix oss   season 2 episode 1 - meetup Lightning talks
Netflix oss season 2 episode 1 - meetup Lightning talks
 
10 things you should know about django
10 things you should know about django10 things you should know about django
10 things you should know about django
 
Django Article V0
Django Article V0Django Article V0
Django Article V0
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
Django Introdcution
Django IntrodcutionDjango Introdcution
Django Introdcution
 
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
 
python full stack course in hyderabad...
python full stack course in hyderabad...python full stack course in hyderabad...
python full stack course in hyderabad...
 
python full stack course in hyderabad...
python full stack course in hyderabad...python full stack course in hyderabad...
python full stack course in hyderabad...
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django Architecture
 
Django dev-env-my-way
Django dev-env-my-wayDjango dev-env-my-way
Django dev-env-my-way
 

Último

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 

Django Beyond Basics Guide

  • 2. Who is this for?
  • 3. NOOB GOOD CHUCKNORRIS What I thought… 
  • 4. NOOB GOOD CHUCKNORRIS It is more like… DESIGNER BIG PICTUREGUY OPERATIONS ADMIN RAILS GUY
  • 6. Disclaimer This presentationdoesnot aim tobe a comprehensiveoverviewof any part of Django. Thereare severaltutorialscoveringvarious aspectsof theframework. Insteadthisis talkis part experiencesharing,part advocacyand part entertainment.
  • 8. It is just a framework!
  • 10. Get the BIG picture
  • 11. The BIG picture slide Thanks to Karen Rustad& Asheesh Laroia
  • 12. Also starring… • Lightweight,standaloneweb serverfor dev • Formserializationand validationsystem • Flexiblecachingframework • Supportfor middlewareclasses atvariouslevels • Internationalizationsystem • Unit testframework
  • 13. Why is Django Awesome?
  • 14. List of awesome-ness • Admin • Security • Greatdocumentation • Friendlycommunity • Stable • Batteriesincluded • OpenSource!
  • 16. Coming from PHP/ASPbackground Step 1: ForgetEverything,esphow easylife was… Step 2:Thinkarchitecturefirst Step3:ThinkaboutSeparationof Concerns Step 4:??? Step 5: Profit!!!
  • 17. 101bad excuses not touse Django
  • 18. But Django is too heavy!
  • 19. Flask from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run() Djangoexampleis onefile& almostthesame size! Django from django.http import HttpResponse from django.conf.urls.defaults import patterns DEBUG=True ROOT_URLCONF = 'pico' DATABASES = { 'default': {} } SECRET_KEY = '0123456789‘ * 50 def index(request): return HttpResponse('Hello World!') urlpatterns = patterns('', (r'^$', index)) $ PYTHONPATH=. django-admin.py runserver 0.0.0.0:8000 --settings=pico
  • 20. No, It is batteries included! (+ cool downloadable apps)
  • 21. But Django is too ugly!
  • 22. Why use: “example.com/product/[0-9]+” ? Isn’t this is much cooler: “example.com/product/{id}” ?  SQL Injection!
  • 23. example.com/product/1 or 1=1 will become: SELECT * FROM Products WHERE ID = 1 OR 1=1
  • 24. EvenDjango will not always save you: “example.com/product/(.+)” Avoid!
  • 25. Be as strict as possible: “example.com/product/[0-9]+”
  • 27. Why not Django? • Unusually highperformanceneeds • ExistingDatabase models? • Migrations? • ORM/Templateisnot enough Inotherwords,youwantto replaceall of Django’s components.Whichyou would eventually?!
  • 28. Best Practices • Distrust outsidedata. Sanitizeeverything! • Don’tleakimplementationdetails. • FatterModels/Managersand LeanerViews • FollowPEP8and readable names • Be asDRY as possible. • Breakdown intoreusable Apps
  • 29. novice questions What is a QuerySet? Why is media separate? Which IDE? How to deploy?
  • 31. Must-learn Python Packages • Pip – Don’tstart withoutthis! • iPython/BPython– Betterthanvanillaconsole • Pudb– Bestdebugger • Fabric– Easydeployment
  • 32. But what goes well with Django?
  • 34. Must-learn Django Packages • Django-debug-toolbar– Only inDEV! • Django_compressor– Notjust compression • Django-extensions– Tonsof goodies • South– Gettingintegrated? • Celery– DelayedGratification • Tastypie*–Build yummy APIs * Or anything that suits you
  • 35. Other cool Django Packages • Djangosocialauth:One app to most Social logins • DjangoPaypal:PayPal Payments Standard & Pro • crispy-forms:NiceHTML for forms • django-taggit:Implement tags easily • Psycopg2: Talk to PostgreSQL, a solid database • django-storages:Store anywhere - Cloud, DB or FTP
  • 37. 1) Create a new Django project 2) Find a3rd party app or create anapp 3) Write/Improve models.py 4) Play with queries onconsole. Run syncdb. 5) Add abare admin.py 6) Add data from admin UI 7) Write views.py. Leverage CBVs 8) If needed, adda model form to forms.py 9) Add views to urls.py 10) Jump to step 3till app looks good 11) jump to step 2 For examples, head to arunrocks.com A simplistic Django workflow…
  • 38. 1) Create a new Django project 2) Find a3rd party app or create an app 3) Write/Improve models.py 4) Play with queries onconsole. Repeat step 3 5) Add abare admin.py 6) Add data from admin UI 7) Write views.py. Leverage CBVs 8) If needed, adda model form to forms.py 9) Add views to urls.py 10) Jump to step 3till app looks good Make friends with Git, South, Fabric… A better Django workflow… $ ./manage.py schemamigration app --initial $ ./manage.py migrate app $ ./manage.py schemamigration app --auto $ git init Write tests.py Fabric/Puppet/Chef
  • 40. Forms are easy! • Use formsas much as possible(Hint:security) • ModelFormscovermost uses case • Butselect whichfields showin ModelForms • Hard set all defaults beforeform.save • FormViewis a greatgenericviewfor forms • Usingbootstrap?Use crispy-formsto savetime
  • 41. Should I use CBVs?
  • 42. Ok, I made a Django site. Now what?
  • 43. Ok, I made a Django site. Now what? • Turn off DEBUG • Use HTTPS logins • Set X-Frame- Optionsheader • Use SESSION_COOKIE_ SECURE • Change /admin/ url Oreasier,go to http://ponycheckup.com/