SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Django at the Disco
An introduction to the Django Web framework and
how it's used by the Discovery Creative team

Rich Leland
Discovery Creative

@richleland
richard_leland@discovery.com
http://creative.discovery.com
What is           ?

• Python Web framework
• Originally developed for The World Company
• Named after jazz guitarist Django Reinhardt
• Released under BSD license in 2005
Who’s using it?

• NASA
• PBS
• Discovery
• National Geographic
• The New York Times
• Broadway
• WNYC
• Google
• LA Times
• LexisNexis
Example project structure
myproject
 __init__.py
 manage.py
 settings.py
 urls.py
 myapp
   __init__.py
   admin.py
   models.py
   urls.py
   views.py
 static
 templates
   myproject
Key Features

• Object-relational mapper
• Automatic admin interface
• Elegant, Regex-based URL design
• Template language
• Cache system
• Internationalization
• Community
Object-relational mapper
from django.db import models

class Network(models.Model):
   """
   Represents a member of our family of Networks.
   """
   visible = models.BooleanField(default=True)
   name = models.CharField(max_length=100)
   slug = models.SlugField(unique=True)
   large_logo = models.ImageField(upload_to='ugc/logos/lg/', blank=True)
   small_logo = models.ImageField(upload_to='ugc/logos/sm/', blank=True)
   link = models.URLField(verify_exists=False, blank=True)

...

# in another file, e.g. views.py:

from myapp.models import Network

Network.objects.all()
Network.objects.get(pk=5)
Network.objects.filter(slug=”some-network”)
Automatic admin interface

class NetworkAdmin(admin.ModelAdmin):
   list_display = ('name', 'admin_logo', 'link', 'visible')

     list_filter = ('visible',)

     search_fields = ('name',)
   prepopulated_fields = {
      'slug': ('name',)
   }


admin.site.register(Network, NetworkAdmin)
Elegant, RegEx-based URL design

from django.conf.urls.defaults import *

urlpatterns = patterns('',
   (r'^admin/doc/', include('django.contrib.admindocs.urls')),
   (r'^admin/(.*)', admin.site.root),

    # included url confs from other apps
    (r'^account/', include('registration.urls')),
    (r'^bookmarks/', include('bookmarks.urls')),
    (r'^messages/', include('mailer.urls')),

    # named url patterns pointing to a view
    url(r'^downloads/add/(?P<content_type_id>[d]+)/(?P<object_id>[d]+)/$',
        'pressweb.media.views.add_download',
        name='add-download'),

    url(r'^$',
       'pressweb.network.views.region_list',
       name='select-region-list'),

)
URL structure breakdown

(r'^admin/doc/', include('django.contrib.admindocs.urls')),
  RegEx pattern                  include of another urls.py




                                                         RegEx pattern
url(r'^networks/(?P<object_id>[d]+)/$',
    view='myapp.views.network_detail',                   views.py
    name='add-download'),                                pattern name
Template system

{% extends "base.html" %}
{% load i18n %}

{% block title %}Bookmarks: {% endblock %}
{% block bodyclass %}bookmarks wide{% endblock %}
{% block bodyid %}{{ network.slug }}{% endblock %}

{% block content %}
   {% if bookmarks %}
   <div class="list-view">
      {% for bookmark in bookmarks %}
      <div class="item {% cycle 'odd' 'even' %}">
         <div class="column1">{{ bookmark.created|date:"F j, Y" }}</div>
         <div class="column2">{{ bookmark.title }}</div>
         <div class="column3"><a href="{{ bookmark.url }}">Go to Page</a></div>
      </div>
      {% endfor %}
   </div>
   {% endif %}
{% endblock %}
Template system

{% extends "base.html" %}
{% load i18n %}

{% block title %}Bookmarks: {% endblock %}
{% block bodyclass %}bookmarks wide{% endblock %}
{% block bodyid %}{{ network.slug }}{% endblock %}

{% block content %}
   {% if bookmarks %}
   <div class="list-view">
     {% for bookmark in bookmarks %}
     <div class="item {% cycle 'odd' 'even' %}">
         <div class="column1">{{ bookmark.created|date:"F j, Y" }}</div>
         <div class="column2">{{ bookmark.title }}</div>
         <div class="column3"><a href="{{ bookmark.url }}">Go to Page</a></div>
     </div>
     {% endfor %}
   </div>
   {% endif %}
{% endblock %}
Cache system

Site-wide cache
MIDDLEWARE_CLASSES = (
  'django.middleware.cache.UpdateCacheMiddleware',
  'django.middleware.common.CommonMiddleware',
  'django.middleware.cache.FetchFromCacheMiddleware',
)



Per-view cache
@cache_page(60 * 15)
def my_view(request):
  ...
Cache system

Template fragment caching
{% load cache %}
{% cache 500 sidebar %}
   .. sidebar ..
{% endcache %}



Low-level cache API
from django.core.cache import cache
cache.set('my_key', 'hello, world!', 30)
cache.get('my_key')
Internationalization

i18n in templates
{% trans "Bookmarks" %}
{% blocktrans %}This object is called {{ obj.name }}{% endblocktrans %}




i18n in modules
from django.utils.translation import ugettext_lazy as _

class MyThing(models.Model):
   name = models.CharField(_('name'), help_text=_('This is the help text'))




Create message files (.po), compile them (.mo)
django-admin.py makemessages -l pt_BR
django-admin.py compilemessages
Contrib Apps

• Authentication
• Admin
• Cache
• Comments
• CSRF
• Email
• i18n
• Jython support
• Serialization
• Syndication
• GIS (GeoDjango)
Community

• Core devs actively involved
• Thousands of community-contributed apps
• IRC: #django and #django-dev
• Mailing lists: django-users and django-developers
• Twitter: @djangotracker
Discovery Creative

• In-house ad agency for Discovery and family of
 networks
• Established 1996
• 100 strong: design, dev, photo, copy, account
 services, motion, prepress, production
• Web team established 2006
 • 2 Django devs
 • 4 Designers/front-end devs
 • 2 Project managers
 • 1 QA manager
• Located in Silver Spring & London
• Service all networks and business units globally
How we’re using Django

• Rapid application development
• Combination of B2B, B2C, in-house apps (directory)
• Working with partners (Siemens, AFI/Silverdocs)
• Saving the company money: 2007: $900k, 2008:
$1.5M
Learn more

• docs.djangoproject.com
• djangobook.com
• djangosnippets.org
• Practical Django Projects
• Djangocon: Sept 8-12 in Portland
• django-district.org
Thank you!

Rich Leland
Discovery Creative

@richleland
richard_leland@discovery.com
http://creative.discovery.com

Weitere ähnliche Inhalte

Was ist angesagt?

HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created itPaul Bearne
 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Ayes Chinmay
 
Drupal as a web framework
Drupal as a web frameworkDrupal as a web framework
Drupal as a web frameworkAdam Kalsey
 
jQuery and Rails, Sitting in a Tree
jQuery and Rails, Sitting in a TreejQuery and Rails, Sitting in a Tree
jQuery and Rails, Sitting in a Treeadamlogic
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoRob Bontekoe
 
Intoduction on Playframework
Intoduction on PlayframeworkIntoduction on Playframework
Intoduction on PlayframeworkKnoldus Inc.
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the TrenchesJonathan Wage
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To jQuerySudar Muthu
 
ZendCon2010 Doctrine MongoDB ODM
ZendCon2010 Doctrine MongoDB ODMZendCon2010 Doctrine MongoDB ODM
ZendCon2010 Doctrine MongoDB ODMJonathan Wage
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012ghnash
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery EssentialsMark Rackley
 

Was ist angesagt? (18)

JQuery
JQueryJQuery
JQuery
 
Diving into php
Diving into phpDiving into php
Diving into php
 
HirshHorn theme: how I created it
HirshHorn theme: how I created itHirshHorn theme: how I created it
HirshHorn theme: how I created it
 
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-10) [Node.js] | NIC/NIELIT Web Technology
 
Drupal as a web framework
Drupal as a web frameworkDrupal as a web framework
Drupal as a web framework
 
J query training
J query trainingJ query training
J query training
 
jQuery and Rails, Sitting in a Tree
jQuery and Rails, Sitting in a TreejQuery and Rails, Sitting in a Tree
jQuery and Rails, Sitting in a Tree
 
Building iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" DominoBuilding iPhone Web Apps using "classic" Domino
Building iPhone Web Apps using "classic" Domino
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Intoduction on Playframework
Intoduction on PlayframeworkIntoduction on Playframework
Intoduction on Playframework
 
jQuery
jQueryjQuery
jQuery
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
A Short Introduction To jQuery
A Short Introduction To jQueryA Short Introduction To jQuery
A Short Introduction To jQuery
 
jQuery
jQueryjQuery
jQuery
 
ZendCon2010 Doctrine MongoDB ODM
ZendCon2010 Doctrine MongoDB ODMZendCon2010 Doctrine MongoDB ODM
ZendCon2010 Doctrine MongoDB ODM
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012
 
jQuery
jQueryjQuery
jQuery
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 

Andere mochten auch

3. pollution detection
3. pollution detection3. pollution detection
3. pollution detectionvanyelindigo
 
Extension task
Extension taskExtension task
Extension taskhwells2101
 
Proyecto Licitación Electrónica Gijón - Resultados 2015
Proyecto Licitación Electrónica Gijón - Resultados 2015Proyecto Licitación Electrónica Gijón - Resultados 2015
Proyecto Licitación Electrónica Gijón - Resultados 2015VORTAL Connecting Business
 
TIC´S - Determinismo, Constructivismo social
TIC´S - Determinismo, Constructivismo socialTIC´S - Determinismo, Constructivismo social
TIC´S - Determinismo, Constructivismo socialProfesorado de Geografia
 
2016_FirstEdition_70124_Rent_Report
2016_FirstEdition_70124_Rent_Report2016_FirstEdition_70124_Rent_Report
2016_FirstEdition_70124_Rent_ReportJustin Cropper
 
The death of franchise
The death of franchiseThe death of franchise
The death of franchiseAnke Saputro
 
Digital insights report 2016 Ireland by Virgin Media
Digital insights report 2016 Ireland by Virgin MediaDigital insights report 2016 Ireland by Virgin Media
Digital insights report 2016 Ireland by Virgin MediaKrishna De
 
Phytotechnology presentation
Phytotechnology presentationPhytotechnology presentation
Phytotechnology presentationErwin Peji
 
Tema5.La ImportàNcia De Les Migracions
Tema5.La ImportàNcia De Les MigracionsTema5.La ImportàNcia De Les Migracions
Tema5.La ImportàNcia De Les Migracionsxavierpinyol
 
Forests and their effects on environment team 4_
Forests and their effects on environment team 4_Forests and their effects on environment team 4_
Forests and their effects on environment team 4_Erasmus+
 
WHO Framework Convention on Tobacco Control
WHO Framework Convention on Tobacco ControlWHO Framework Convention on Tobacco Control
WHO Framework Convention on Tobacco ControlSmoke-Free Albay Network
 
Digitales Marketing für kleinere Unternehmen
Digitales Marketing für kleinere UnternehmenDigitales Marketing für kleinere Unternehmen
Digitales Marketing für kleinere UnternehmenMuller Gracio Manalu
 
Ueda2016 symposium -t2 dm management - lobna el toony
Ueda2016 symposium -t2 dm management  - lobna el toonyUeda2016 symposium -t2 dm management  - lobna el toony
Ueda2016 symposium -t2 dm management - lobna el toonyueda2015
 
Studie cloud security 2016
Studie cloud security 2016Studie cloud security 2016
Studie cloud security 2016Andreas Pelka
 
Guión comentario paisaje rural
Guión comentario paisaje ruralGuión comentario paisaje rural
Guión comentario paisaje ruralRocío Bautista
 
Makalah Bahasa Indonesia Menulis Alinea
Makalah Bahasa Indonesia Menulis AlineaMakalah Bahasa Indonesia Menulis Alinea
Makalah Bahasa Indonesia Menulis AlineaFAJAR MENTARI
 
Primary hyperparathyroidism
Primary hyperparathyroidismPrimary hyperparathyroidism
Primary hyperparathyroidismJunaid Sofi
 

Andere mochten auch (18)

3. pollution detection
3. pollution detection3. pollution detection
3. pollution detection
 
Extension task
Extension taskExtension task
Extension task
 
Proyecto Licitación Electrónica Gijón - Resultados 2015
Proyecto Licitación Electrónica Gijón - Resultados 2015Proyecto Licitación Electrónica Gijón - Resultados 2015
Proyecto Licitación Electrónica Gijón - Resultados 2015
 
TIC´S - Determinismo, Constructivismo social
TIC´S - Determinismo, Constructivismo socialTIC´S - Determinismo, Constructivismo social
TIC´S - Determinismo, Constructivismo social
 
2016_FirstEdition_70124_Rent_Report
2016_FirstEdition_70124_Rent_Report2016_FirstEdition_70124_Rent_Report
2016_FirstEdition_70124_Rent_Report
 
The death of franchise
The death of franchiseThe death of franchise
The death of franchise
 
Digital insights report 2016 Ireland by Virgin Media
Digital insights report 2016 Ireland by Virgin MediaDigital insights report 2016 Ireland by Virgin Media
Digital insights report 2016 Ireland by Virgin Media
 
Phytotechnology presentation
Phytotechnology presentationPhytotechnology presentation
Phytotechnology presentation
 
Tema5.La ImportàNcia De Les Migracions
Tema5.La ImportàNcia De Les MigracionsTema5.La ImportàNcia De Les Migracions
Tema5.La ImportàNcia De Les Migracions
 
Forests and their effects on environment team 4_
Forests and their effects on environment team 4_Forests and their effects on environment team 4_
Forests and their effects on environment team 4_
 
WHO Framework Convention on Tobacco Control
WHO Framework Convention on Tobacco ControlWHO Framework Convention on Tobacco Control
WHO Framework Convention on Tobacco Control
 
Digitales Marketing für kleinere Unternehmen
Digitales Marketing für kleinere UnternehmenDigitales Marketing für kleinere Unternehmen
Digitales Marketing für kleinere Unternehmen
 
Ueda2016 symposium -t2 dm management - lobna el toony
Ueda2016 symposium -t2 dm management  - lobna el toonyUeda2016 symposium -t2 dm management  - lobna el toony
Ueda2016 symposium -t2 dm management - lobna el toony
 
Studie cloud security 2016
Studie cloud security 2016Studie cloud security 2016
Studie cloud security 2016
 
Guión comentario paisaje rural
Guión comentario paisaje ruralGuión comentario paisaje rural
Guión comentario paisaje rural
 
Makalah Bahasa Indonesia Menulis Alinea
Makalah Bahasa Indonesia Menulis AlineaMakalah Bahasa Indonesia Menulis Alinea
Makalah Bahasa Indonesia Menulis Alinea
 
Primary hyperparathyroidism
Primary hyperparathyroidismPrimary hyperparathyroidism
Primary hyperparathyroidism
 
Medical applications of Nanotech. in cancer therapy
Medical applications of Nanotech. in cancer therapyMedical applications of Nanotech. in cancer therapy
Medical applications of Nanotech. in cancer therapy
 

Ähnlich wie Django at the Disco

Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Eric Palakovich Carr
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
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
 
How Not to Build a WordPress Plugin
How Not to Build a WordPress PluginHow Not to Build a WordPress Plugin
How Not to Build a WordPress PluginWill Norris
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction DjangoWade Austin
 
Templates
TemplatesTemplates
Templatessoon
 
WordPress for developers - phpday 2011
WordPress for developers -  phpday 2011WordPress for developers -  phpday 2011
WordPress for developers - phpday 2011Maurizio Pelizzone
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 
The new static resources framework
The new static resources frameworkThe new static resources framework
The new static resources frameworkmarcplmer
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of DjangoJacob Kaplan-Moss
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Luka Zakrajšek
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!David Gibbons
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Hugo Hamon
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Djangofool2nd
 
Multilingualism makes better programmers
Multilingualism makes better programmersMultilingualism makes better programmers
Multilingualism makes better programmersAlexander Varwijk
 

Ähnlich wie Django at the Disco (20)

Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
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
 
How Not to Build a WordPress Plugin
How Not to Build a WordPress PluginHow Not to Build a WordPress Plugin
How Not to Build a WordPress Plugin
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
Templates
TemplatesTemplates
Templates
 
WordPress for developers - phpday 2011
WordPress for developers -  phpday 2011WordPress for developers -  phpday 2011
WordPress for developers - phpday 2011
 
Django crush course
Django crush course Django crush course
Django crush course
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
The new static resources framework
The new static resources frameworkThe new static resources framework
The new static resources framework
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of Django
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)
 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Tornadoweb
TornadowebTornadoweb
Tornadoweb
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 
Multilingualism makes better programmers
Multilingualism makes better programmersMultilingualism makes better programmers
Multilingualism makes better programmers
 

Mehr von Richard Leland

Living in harmony - a brief into to ES6
Living in harmony - a brief into to ES6Living in harmony - a brief into to ES6
Living in harmony - a brief into to ES6Richard Leland
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task QueueRichard Leland
 
django-district October
django-district Octoberdjango-district October
django-district OctoberRichard Leland
 

Mehr von Richard Leland (6)

Living in harmony - a brief into to ES6
Living in harmony - a brief into to ES6Living in harmony - a brief into to ES6
Living in harmony - a brief into to ES6
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
 
django-district October
django-district Octoberdjango-district October
django-district October
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django at the Disco
Django at the DiscoDjango at the Disco
Django at the Disco
 
Django District April
Django District AprilDjango District April
Django District April
 

Kürzlich hochgeladen

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
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
 
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
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Kürzlich hochgeladen (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
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
 
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
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Django at the Disco

  • 1. Django at the Disco An introduction to the Django Web framework and how it's used by the Discovery Creative team Rich Leland Discovery Creative @richleland richard_leland@discovery.com http://creative.discovery.com
  • 2. What is ? • Python Web framework • Originally developed for The World Company • Named after jazz guitarist Django Reinhardt • Released under BSD license in 2005
  • 3. Who’s using it? • NASA • PBS • Discovery • National Geographic • The New York Times • Broadway • WNYC • Google • LA Times • LexisNexis
  • 4. Example project structure myproject __init__.py manage.py settings.py urls.py myapp __init__.py admin.py models.py urls.py views.py static templates myproject
  • 5. Key Features • Object-relational mapper • Automatic admin interface • Elegant, Regex-based URL design • Template language • Cache system • Internationalization • Community
  • 6. Object-relational mapper from django.db import models class Network(models.Model): """ Represents a member of our family of Networks. """ visible = models.BooleanField(default=True) name = models.CharField(max_length=100) slug = models.SlugField(unique=True) large_logo = models.ImageField(upload_to='ugc/logos/lg/', blank=True) small_logo = models.ImageField(upload_to='ugc/logos/sm/', blank=True) link = models.URLField(verify_exists=False, blank=True) ... # in another file, e.g. views.py: from myapp.models import Network Network.objects.all() Network.objects.get(pk=5) Network.objects.filter(slug=”some-network”)
  • 7. Automatic admin interface class NetworkAdmin(admin.ModelAdmin): list_display = ('name', 'admin_logo', 'link', 'visible') list_filter = ('visible',) search_fields = ('name',) prepopulated_fields = { 'slug': ('name',) } admin.site.register(Network, NetworkAdmin)
  • 8.
  • 9.
  • 10. Elegant, RegEx-based URL design from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^admin/doc/', include('django.contrib.admindocs.urls')), (r'^admin/(.*)', admin.site.root), # included url confs from other apps (r'^account/', include('registration.urls')), (r'^bookmarks/', include('bookmarks.urls')), (r'^messages/', include('mailer.urls')), # named url patterns pointing to a view url(r'^downloads/add/(?P<content_type_id>[d]+)/(?P<object_id>[d]+)/$', 'pressweb.media.views.add_download', name='add-download'), url(r'^$', 'pressweb.network.views.region_list', name='select-region-list'), )
  • 11. URL structure breakdown (r'^admin/doc/', include('django.contrib.admindocs.urls')), RegEx pattern include of another urls.py RegEx pattern url(r'^networks/(?P<object_id>[d]+)/$', view='myapp.views.network_detail', views.py name='add-download'), pattern name
  • 12. Template system {% extends "base.html" %} {% load i18n %} {% block title %}Bookmarks: {% endblock %} {% block bodyclass %}bookmarks wide{% endblock %} {% block bodyid %}{{ network.slug }}{% endblock %} {% block content %} {% if bookmarks %} <div class="list-view"> {% for bookmark in bookmarks %} <div class="item {% cycle 'odd' 'even' %}"> <div class="column1">{{ bookmark.created|date:"F j, Y" }}</div> <div class="column2">{{ bookmark.title }}</div> <div class="column3"><a href="{{ bookmark.url }}">Go to Page</a></div> </div> {% endfor %} </div> {% endif %} {% endblock %}
  • 13. Template system {% extends "base.html" %} {% load i18n %} {% block title %}Bookmarks: {% endblock %} {% block bodyclass %}bookmarks wide{% endblock %} {% block bodyid %}{{ network.slug }}{% endblock %} {% block content %} {% if bookmarks %} <div class="list-view"> {% for bookmark in bookmarks %} <div class="item {% cycle 'odd' 'even' %}"> <div class="column1">{{ bookmark.created|date:"F j, Y" }}</div> <div class="column2">{{ bookmark.title }}</div> <div class="column3"><a href="{{ bookmark.url }}">Go to Page</a></div> </div> {% endfor %} </div> {% endif %} {% endblock %}
  • 14. Cache system Site-wide cache MIDDLEWARE_CLASSES = ( 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.cache.FetchFromCacheMiddleware', ) Per-view cache @cache_page(60 * 15) def my_view(request): ...
  • 15. Cache system Template fragment caching {% load cache %} {% cache 500 sidebar %} .. sidebar .. {% endcache %} Low-level cache API from django.core.cache import cache cache.set('my_key', 'hello, world!', 30) cache.get('my_key')
  • 16. Internationalization i18n in templates {% trans "Bookmarks" %} {% blocktrans %}This object is called {{ obj.name }}{% endblocktrans %} i18n in modules from django.utils.translation import ugettext_lazy as _ class MyThing(models.Model): name = models.CharField(_('name'), help_text=_('This is the help text')) Create message files (.po), compile them (.mo) django-admin.py makemessages -l pt_BR django-admin.py compilemessages
  • 17. Contrib Apps • Authentication • Admin • Cache • Comments • CSRF • Email • i18n • Jython support • Serialization • Syndication • GIS (GeoDjango)
  • 18. Community • Core devs actively involved • Thousands of community-contributed apps • IRC: #django and #django-dev • Mailing lists: django-users and django-developers • Twitter: @djangotracker
  • 19. Discovery Creative • In-house ad agency for Discovery and family of networks • Established 1996 • 100 strong: design, dev, photo, copy, account services, motion, prepress, production • Web team established 2006 • 2 Django devs • 4 Designers/front-end devs • 2 Project managers • 1 QA manager • Located in Silver Spring & London • Service all networks and business units globally
  • 20. How we’re using Django • Rapid application development • Combination of B2B, B2C, in-house apps (directory) • Working with partners (Siemens, AFI/Silverdocs) • Saving the company money: 2007: $900k, 2008: $1.5M
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. Learn more • docs.djangoproject.com • djangobook.com • djangosnippets.org • Practical Django Projects • Djangocon: Sept 8-12 in Portland • django-district.org
  • 26. Thank you! Rich Leland Discovery Creative @richleland richard_leland@discovery.com http://creative.discovery.com