SlideShare a Scribd company logo
A Quick Overview
A bit about me

•   Programmer @ 5Q Communications
•   Hack on Django mostly full-time
•   Dozen+ sites in production
•   Calvin grad
A bit about Django

•   Named after Django Reinhart, jazz guitarist
•   Python 2.3+ (Not 3.x yet, afiak)
•   BSD license
•   djangoproject.com
•   Current release: 1.1
Who uses it?
•   NASA
•   PBS
•   NY Times
•   LA Times
•   National Geographic
•   Discovery Channel
Features

•   Object-Relational     •   i18n/unicode support
    Mapper
                          •   Cache framework
•   MVC architecture
                          •   Testing framework
•   Templating Language
                          •   Great docs (650+ pages)
•   “Automatic” admins
                          •   Friendly community
•   Elegant urls
More Features

•   Jython support        •   Built-in RSS/ATOM
•   Geospacial content    •   Built-in site maps
    (via GeoDjango)
                          •   Send emails easily
•   Built-in dev server
                          •   “Signal” hooks
•   Nice support
                          •   Solid security emphasis
    for forms
Projects and Apps
Settings: database,               App   Live anywhere in your
email, caching, etc.   Project          PYTHONPATH
                                  App


      HTML, CSS,                  App
      images, etc. Templates
                       & Assets   App
Typical Project Layout
       project/
         __init__.py
         settings.py
         manage.py
         urls.py
         templates/
         static/
         staff_members/
            __init__.py
            models.py
            admin.py
            views.py
            urls.py
            tests.py
            templates/
Typical App Workflow

1. Create app
2. Create models.py and admin.py
3. ‘python manage.py syncdb’
4. Create urls.py and views.py
class StaffMemberGroup(models.Model):
   name = models.CharField(blank=True, max_length=100)
   order = models.IntegerField(blank=True, null=True)

class StaffMember(models.Model):
   first_name = models.CharField(max_length=100)
   last_name = models.CharField(max_length=100)
   title = models.CharField(blank=True, max_length=100)
   bio = models.TextField(blank=True)
   image = models.FileField(upload_to='bio_images', blank=True)
   email = models.EmailField()
   published = models.BooleanField()
   staff_group = models.ForeignKey(StaffMemberGroup)
python manage.py syncdb

1. Create tables
2. Create basic indexes
3. Create intermediate tables
   for m2m relationships
bob = StaffMember(first_name=”Bob”, last_name=”Smith”)

members = StaffMember.objects.all()

ordered_members =
 StaffMember.objects.all().order_by(‘last_name’)

published_members =
 StaffMember.objects.filter(published=True)
groups = StaffMemberGroup.objects.all()

for group in groups:
  print group.name
    for member in group.staffmember_set.all():
       print member.first_name
class StaffMemberAdmin(admin.ModelAdmin):
   list_display = ('last_name', 'first_name', 'email', 'published')
   list_filter = ('published', 'staff_group')
   search_fields = ('first_name', 'last_name', 'bio', 'title', 'email')
   fieldsets = (
       (None, {
           'fields': (('first_name', 'last_name'), 'title', 'email', 'image', 'bio'),
           'description': '',
       }),
       ('Options', {
           'fields': ('published', 'staff_group'),
       })
   )
admin.site.register(StaffMember, StaffMemberAdmin)
project urls.py
urlpatterns = patterns('',
   (r'^staff_members/', include('grpug.staff_members.urls')),
   (r'^admin/doc/', include('django.contrib.admindocs.urls')),
   (r'^admin/(.*)', admin.site.root),
)


staff_members app urls.py:
urlpatterns = patterns('grpug.staff_members.views',
   url(r'^$', 'show_staff_members', name='staff-members'),
)
def show_staff_members(request):
  groups = StaffMemberGroup.objects.all()
  return render_to_response(
     'staff_member.html',
     {'groups': groups}
  )
staff_member.html
{% for group in groups %}
  <h2>{{group.name}}</h2>
  <ul>
     {% for member in group.staffmember_set.all %}
        <li>
        <h3>{{member.first_name}} {{member.last_name}}</h3>
        <p>{{member.bio}}</p>
        </li>
     {% endfor %}
  </ul>
{% endfor %}
staff_member.html
{% extends ‘base_site.html’ %}

  {% block content %}
  {% for group in groups %}
    <h2>{{group.name}}</h2>
    <ul>
       {% for member in group.staffmember_set.all %}
          <li>
          <h3>{{member.first_name}} {{member.last_name}}</h3>
          <p>{{member.bio}}</p>
          </li>
       {% endfor %}
    </ul>
  {% endfor %}
{% endblock content %}
base_site.html
  <html>
  <body>
    {% block content %}
    {% endblock content %}
  </body>
  </html>
Middleware

•   process_request(self, request)
•   process_view(self, request, view_func,
      view_args, view_kwargs)
•   process_response(self, request, response)
•   process_exception(self, request, exception)
Testing Framework

•   doctests
•   unit tests
•   helpful stuff: fixtures, email test, “client”

    c = Client()
    response = c.post(‘/login’, user_dict)
Some Warts
•   No support for           •   REST/SOAP
    multiple databases           support lacking
•   Poor environment         •   “Explicit” but still tightly
    support (think rails)        coupled for some things
•   Template logic tags      •   No integrated
    below average                deployment toolchain
•   No built-in migrations   •   CMS extras lacking
                                 (wysiwyg, file browser...)
•   Too big?
Rest of the stack

•   Databases        •       Deployment
    •   SQLite           •    mod_python
    •   MySQL            •    mod_wsgi
    •   Postgresql       •    fast cgi
    •   Oracle
Tips
•   virtualenv is your friend
•   default settings.py is about 50% of what a
    production site ends up requiring
•   local_settings.py
•   Don’t be afraid of lots of apps
•   ‘South’ is a solid migrations tool
Docs, Books, People

•   docs.djangoproject.com
•   djangobook.com
•   djangosnippets.com
•   djangopeople.net
•   djangosites.org
Code Samples


•   http://bitbucket.org/btol45/grpug-example/

More Related Content

What's hot

Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
colinkingswood
 
Tango with django
Tango with djangoTango with django
Tango with django
Rajan Kumar Upadhyay
 
The Django Book - Chapter 5: Models
The Django Book - Chapter 5: ModelsThe Django Book - Chapter 5: Models
The Django Book - Chapter 5: Models
Sharon Chen
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
Nathan Eror
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Djangofool2nd
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play Nice
Alex Gaynor
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
Wade Austin
 
Django
DjangoDjango
Django a whirlwind tour
Django   a whirlwind tourDjango   a whirlwind tour
Django a whirlwind tour
Brad Montgomery
 
A gentle intro to the Django Framework
A gentle intro to the Django FrameworkA gentle intro to the Django Framework
A gentle intro to the Django FrameworkRicardo Soares
 
Intro to Web Development Using Python and Django
Intro to Web Development Using Python and DjangoIntro to Web Development Using Python and Django
Intro to Web Development Using Python and Django
Chariza Pladin
 
Selenium&amp;scrapy
Selenium&amp;scrapySelenium&amp;scrapy
Selenium&amp;scrapy
Arcangelo Saracino
 
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
 
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
 
Djangocon 2014 angular + django
Djangocon 2014 angular + djangoDjangocon 2014 angular + django
Djangocon 2014 angular + django
Nina Zakharenko
 
Google App Engine with Gaelyk
Google App Engine with GaelykGoogle App Engine with Gaelyk
Google App Engine with Gaelyk
Choong Ping Teo
 
Django REST Framework
Django REST FrameworkDjango REST Framework
Django REST Framework
Load Impact
 
Django and Mongoengine
Django and MongoengineDjango and Mongoengine
Django and Mongoengineaustinpublic
 
Geotalk presentation
Geotalk presentationGeotalk presentation
Geotalk presentation
Eric Palakovich Carr
 

What's hot (20)

Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Tango with django
Tango with djangoTango with django
Tango with django
 
The Django Book - Chapter 5: Models
The Django Book - Chapter 5: ModelsThe Django Book - Chapter 5: Models
The Django Book - Chapter 5: Models
 
Building a Dynamic Website Using Django
Building a Dynamic Website Using DjangoBuilding a Dynamic Website Using Django
Building a Dynamic Website Using Django
 
Gae Meets Django
Gae Meets DjangoGae Meets Django
Gae Meets Django
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play Nice
 
Introduction Django
Introduction DjangoIntroduction Django
Introduction Django
 
Django
DjangoDjango
Django
 
Django a whirlwind tour
Django   a whirlwind tourDjango   a whirlwind tour
Django a whirlwind tour
 
A gentle intro to the Django Framework
A gentle intro to the Django FrameworkA gentle intro to the Django Framework
A gentle intro to the Django Framework
 
Intro to Web Development Using Python and Django
Intro to Web Development Using Python and DjangoIntro to Web Development Using Python and Django
Intro to Web Development Using Python and Django
 
Selenium&amp;scrapy
Selenium&amp;scrapySelenium&amp;scrapy
Selenium&amp;scrapy
 
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!
 
The Best (and Worst) of Django
The Best (and Worst) of DjangoThe Best (and Worst) of Django
The Best (and Worst) of Django
 
Djangocon 2014 angular + django
Djangocon 2014 angular + djangoDjangocon 2014 angular + django
Djangocon 2014 angular + django
 
Google App Engine with Gaelyk
Google App Engine with GaelykGoogle App Engine with Gaelyk
Google App Engine with Gaelyk
 
Django REST Framework
Django REST FrameworkDjango REST Framework
Django REST Framework
 
Django and Mongoengine
Django and MongoengineDjango and Mongoengine
Django and Mongoengine
 
Django Mongodb Engine
Django Mongodb EngineDjango Mongodb Engine
Django Mongodb Engine
 
Geotalk presentation
Geotalk presentationGeotalk presentation
Geotalk presentation
 

Viewers also liked

Jumpstart Django
Jumpstart DjangoJumpstart Django
Jumpstart Django
ryates
 
Free django
Free djangoFree django
Free django
Eugen Oskin
 
Getting Started With Django
Getting Started With DjangoGetting Started With Django
Getting Started With Django
jeff_croft
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
Jason Davies
 
12 tips on Django Best Practices
12 tips on Django Best Practices12 tips on Django Best Practices
12 tips on Django Best Practices
David Arcos
 
Django Best Practices
Django Best PracticesDjango Best Practices
Django Best Practices
Abdullah Çetin ÇAVDAR
 
Python Presentation
Python PresentationPython Presentation
Python Presentation
Narendra Sisodiya
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
Michael Pirnat
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
Matt Harrison
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Nowell Strite
 

Viewers also liked (12)

Jumpstart Django
Jumpstart DjangoJumpstart Django
Jumpstart Django
 
Free django
Free djangoFree django
Free django
 
Getting Started With Django
Getting Started With DjangoGetting Started With Django
Getting Started With Django
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Django introduction
Django introductionDjango introduction
Django introduction
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
12 tips on Django Best Practices
12 tips on Django Best Practices12 tips on Django Best Practices
12 tips on Django Best Practices
 
Django Best Practices
Django Best PracticesDjango Best Practices
Django Best Practices
 
Python Presentation
Python PresentationPython Presentation
Python Presentation
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 

Similar to Django Overview

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
 
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
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAE
Winston Chen
 
Python & Django TTT
Python & Django TTTPython & Django TTT
Python & Django TTTkevinvw
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
Oscar Merida
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb
Leo Zhou
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojo
Fu Cheng
 
BackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applicationsBackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applications
Joseph Khan
 
Python - A Comprehensive Programming Language
Python - A Comprehensive Programming LanguagePython - A Comprehensive Programming Language
Python - A Comprehensive Programming Language
TsungWei Hu
 
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Lucidworks
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to TornadoGavin Roy
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGentkevinvw
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An Introduction
Thorsten Kamann
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jussi Pohjolainen
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your WebsiteAcquia
 
Open Social In The Enterprise
Open Social In The EnterpriseOpen Social In The Enterprise
Open Social In The EnterpriseTim Moore
 
12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat
linoj
 
Introduction to Monsoon PHP framework
Introduction to Monsoon PHP frameworkIntroduction to Monsoon PHP framework
Introduction to Monsoon PHP framework
Krishna Srikanth Manda
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
Derek Jacoby
 

Similar to Django Overview (20)

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
 
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)
 
國民雲端架構 Django + GAE
國民雲端架構 Django + GAE國民雲端架構 Django + GAE
國民雲端架構 Django + GAE
 
Python & Django TTT
Python & Django TTTPython & Django TTT
Python & Django TTT
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 
1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb1.6 米嘉 gobuildweb
1.6 米嘉 gobuildweb
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojo
 
JS Essence
JS EssenceJS Essence
JS Essence
 
BackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applicationsBackboneJS Training - Giving Backbone to your applications
BackboneJS Training - Giving Backbone to your applications
 
Python - A Comprehensive Programming Language
Python - A Comprehensive Programming LanguagePython - A Comprehensive Programming Language
Python - A Comprehensive Programming Language
 
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An Introduction
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
5 Common Mistakes You are Making on your Website
 5 Common Mistakes You are Making on your Website 5 Common Mistakes You are Making on your Website
5 Common Mistakes You are Making on your Website
 
Open Social In The Enterprise
Open Social In The EnterpriseOpen Social In The Enterprise
Open Social In The Enterprise
 
12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat12 core technologies you should learn, love, and hate to be a 'real' technocrat
12 core technologies you should learn, love, and hate to be a 'real' technocrat
 
Introduction to Monsoon PHP framework
Introduction to Monsoon PHP frameworkIntroduction to Monsoon PHP framework
Introduction to Monsoon PHP framework
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
 

Recently uploaded

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 

Django Overview

  • 2. A bit about me • Programmer @ 5Q Communications • Hack on Django mostly full-time • Dozen+ sites in production • Calvin grad
  • 3.
  • 4. A bit about Django • Named after Django Reinhart, jazz guitarist • Python 2.3+ (Not 3.x yet, afiak) • BSD license • djangoproject.com • Current release: 1.1
  • 5.
  • 6. Who uses it? • NASA • PBS • NY Times • LA Times • National Geographic • Discovery Channel
  • 7. Features • Object-Relational • i18n/unicode support Mapper • Cache framework • MVC architecture • Testing framework • Templating Language • Great docs (650+ pages) • “Automatic” admins • Friendly community • Elegant urls
  • 8. More Features • Jython support • Built-in RSS/ATOM • Geospacial content • Built-in site maps (via GeoDjango) • Send emails easily • Built-in dev server • “Signal” hooks • Nice support • Solid security emphasis for forms
  • 9. Projects and Apps Settings: database, App Live anywhere in your email, caching, etc. Project PYTHONPATH App HTML, CSS, App images, etc. Templates & Assets App
  • 10. Typical Project Layout project/ __init__.py settings.py manage.py urls.py templates/ static/ staff_members/ __init__.py models.py admin.py views.py urls.py tests.py templates/
  • 11. Typical App Workflow 1. Create app 2. Create models.py and admin.py 3. ‘python manage.py syncdb’ 4. Create urls.py and views.py
  • 12. class StaffMemberGroup(models.Model): name = models.CharField(blank=True, max_length=100) order = models.IntegerField(blank=True, null=True) class StaffMember(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) title = models.CharField(blank=True, max_length=100) bio = models.TextField(blank=True) image = models.FileField(upload_to='bio_images', blank=True) email = models.EmailField() published = models.BooleanField() staff_group = models.ForeignKey(StaffMemberGroup)
  • 13. python manage.py syncdb 1. Create tables 2. Create basic indexes 3. Create intermediate tables for m2m relationships
  • 14. bob = StaffMember(first_name=”Bob”, last_name=”Smith”) members = StaffMember.objects.all() ordered_members = StaffMember.objects.all().order_by(‘last_name’) published_members = StaffMember.objects.filter(published=True)
  • 15. groups = StaffMemberGroup.objects.all() for group in groups: print group.name for member in group.staffmember_set.all(): print member.first_name
  • 16. class StaffMemberAdmin(admin.ModelAdmin): list_display = ('last_name', 'first_name', 'email', 'published') list_filter = ('published', 'staff_group') search_fields = ('first_name', 'last_name', 'bio', 'title', 'email') fieldsets = ( (None, { 'fields': (('first_name', 'last_name'), 'title', 'email', 'image', 'bio'), 'description': '', }), ('Options', { 'fields': ('published', 'staff_group'), }) ) admin.site.register(StaffMember, StaffMemberAdmin)
  • 17.
  • 18.
  • 19.
  • 20. project urls.py urlpatterns = patterns('', (r'^staff_members/', include('grpug.staff_members.urls')), (r'^admin/doc/', include('django.contrib.admindocs.urls')), (r'^admin/(.*)', admin.site.root), ) staff_members app urls.py: urlpatterns = patterns('grpug.staff_members.views', url(r'^$', 'show_staff_members', name='staff-members'), )
  • 21. def show_staff_members(request): groups = StaffMemberGroup.objects.all() return render_to_response( 'staff_member.html', {'groups': groups} )
  • 22. staff_member.html {% for group in groups %} <h2>{{group.name}}</h2> <ul> {% for member in group.staffmember_set.all %} <li> <h3>{{member.first_name}} {{member.last_name}}</h3> <p>{{member.bio}}</p> </li> {% endfor %} </ul> {% endfor %}
  • 23. staff_member.html {% extends ‘base_site.html’ %} {% block content %} {% for group in groups %} <h2>{{group.name}}</h2> <ul> {% for member in group.staffmember_set.all %} <li> <h3>{{member.first_name}} {{member.last_name}}</h3> <p>{{member.bio}}</p> </li> {% endfor %} </ul> {% endfor %} {% endblock content %}
  • 24. base_site.html <html> <body> {% block content %} {% endblock content %} </body> </html>
  • 25. Middleware • process_request(self, request) • process_view(self, request, view_func, view_args, view_kwargs) • process_response(self, request, response) • process_exception(self, request, exception)
  • 26. Testing Framework • doctests • unit tests • helpful stuff: fixtures, email test, “client” c = Client() response = c.post(‘/login’, user_dict)
  • 27. Some Warts • No support for • REST/SOAP multiple databases support lacking • Poor environment • “Explicit” but still tightly support (think rails) coupled for some things • Template logic tags • No integrated below average deployment toolchain • No built-in migrations • CMS extras lacking (wysiwyg, file browser...) • Too big?
  • 28. Rest of the stack • Databases • Deployment • SQLite • mod_python • MySQL • mod_wsgi • Postgresql • fast cgi • Oracle
  • 29. Tips • virtualenv is your friend • default settings.py is about 50% of what a production site ends up requiring • local_settings.py • Don’t be afraid of lots of apps • ‘South’ is a solid migrations tool
  • 30. Docs, Books, People • docs.djangoproject.com • djangobook.com • djangosnippets.com • djangopeople.net • djangosites.org
  • 31. Code Samples • http://bitbucket.org/btol45/grpug-example/