SlideShare a Scribd company logo
RESTing with
 DJANGO




   Fernando Ciciliati
   Python Ireland November Meet-up
   10/11/2010 – The Science Gallery – Dublin
Contents
●   Quick review of REST ?
●   Even quicker review of Django ?
●   Let's REST with Django...
REST
Practical REST

●   Building a web for computers
    ●   They (computers) want to find 'computer-friendly'
        pages
    ●   They love well organised data/information
    ●   They don't mind about ”visual appeal”
●   Side note: There is no ”Google” for them [yet].
REST Keywords
●   Resource
●   ”Resource name” or URI [or URL]
●   Representation
●   Methods/Verbs (Uniform Interface)
●   Links
REST: Resource
●   Any entity, object or concept we want our
    application to keep information about
●   Obvious resources:
    ●   Books, people, employees, cities, blog entries, bank
        accounts, hotels, flights, ..
●   Slightly less obvious:
    ●   Money transfers, hotel reservations, flight tickets, …
●   Even less obvious:
    ●   User session, transaction, ...
REST: Resource Name
●   Every resource should receive at least one
    name that identifies it uniquely in its context of
    usage or existence – ideally, in the world.
●   This name should be durable, persistent.
●   Typical naming schemas: URLs, URIs, URNs
●   It is OK to have more than one name identifying
    the same resource
REST: Representation
●   Representations are the materialization, in
    bytes and bits, of resources.
●   Resources are ideas, concepts; representations
    are ”physical”, ”tangible” REPRESENTATIONS
    of ideas
●   Multiple formats possible
●   A single resource can have multiple
    representations associated to it
REST: Uniform Interface
●   Minimize number of ”verbs”
    ●   REST x ”WebServices”
●   Stick to HTTP verbs
Core REST principles
●   Addressability
●   State and statelessness
●   Conectedness
●   Uniform Interface
    ●   Safety and Idempotence
HTTP
●   HTTP is your best friend
●   Requests
●   Headers
●   Body
●   Status (return) codes
    ●   2xx – Success
    ●   3xx – ???
    ●   4xx – ???
    ●   5xx – Server Error
Django + REST
General Approach

                                   urls.py
 urls.py                                                 JSON
                   HTML



                                             views.py
            views.py



                                             models.py
models.py

                       templates
Methods
●   OPTIONS
    ●   Should be always available with any URI
    ●   Returns a list of available methods for that URI in the
        ”Allow” header of the HTTP response;
●   GET
    ●   on a collection URI returns a list of items in that collection
        –   for large collections, consider paging
    ●   on an item's URI returns a representation of that item
        (resource)
    ●   ”Safe”
Methods (contd.)
●   POST
    ●   Points to a collection URI
    ●   Creates a new resource in that collection
    ●   We don't know the resource-id beforehand
    ●   Not idempotent!
●   PUT
    ●   Points to an item URI
    ●   We KNOW the resource-id
    ●   Creates a new resource or updated an existing one
    ●   Idempotent
Methods (contd.)
●   DELETE
    ●   Usually points to a resouce URI
    ●   Deletes the resource
    ●   Retry strategy is not a problem
●   HEAD
    ●   Like GET, but returns only headers, no body
    ●   Good for retrieving information about the resource
        as its size, language, content type, etc., without
        transmitting the entire resource.
Recommended Tools
●   Firefox 3.x
    ●   FireBug (Net tab) or HTTPFox
    ●   Poster
    ●   SQLite Manager
    ●   JSONView
    ●   Modify Headers
●   Wireshark
Recommended Books
RESTful Web Services, Leonard     Pro Django, Marty Alchin, Apress
Richardson & Sam Ruby, O'Reilly

More Related Content

PDF
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
PDF
Microformats I: What & Why
PPTX
IPTC News in JSON Spring 2013
PDF
Search Concepts & Tools
PPTX
2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...
PDF
JustJava 2005: Web Services em Java com o JWSDP 1.5
PDF
Publishing Linked Data using Schema.org
PPTX
Ontology Access Kit_ Workshop Intro Slides.pptx
PostgreSQL, Extensible to the Nth Degree: Functions, Languages, Types, Rules,...
Microformats I: What & Why
IPTC News in JSON Spring 2013
Search Concepts & Tools
2016.02 - Validating RDF Data Quality using Constraints to Direct the Develop...
JustJava 2005: Web Services em Java com o JWSDP 1.5
Publishing Linked Data using Schema.org
Ontology Access Kit_ Workshop Intro Slides.pptx

Similar to Python Ireland Nov 2010 - RESTing with Django (20)

ODP
REST API Laravel
PDF
The Semantic Web and Drupal 7 - Loja 2013
PDF
A content repository for your PHP application or CMS?
PDF
Drupal and the Semantic Web - ESIP Webinar
PDF
Getting started with DSpace 7 REST API
PDF
Development without Constraint
PDF
GraphQL is actually rest
PDF
The Future of Search and SEO in Drupal
PPTX
Hacktoberfest 2020 - Intro to Knowledge Graphs
PDF
NoSQL
PDF
MongoDB Basics
PDF
Devoxx 2008 - REST in Peace
PPTX
A Deep Dive into RESTful API Design Part 2
PDF
Slides semantic web and Drupal 7 NYCCamp 2012
PPTX
Pragmatic REST APIs
PDF
Drupal and the semantic web - SemTechBiz 2012
PDF
Java Web Services [5/5]: REST and JAX-RS
PDF
Intro to Hypermedia APIs
PPTX
Restful webservice
PDF
Real time semantic search engine for social tv streams
REST API Laravel
The Semantic Web and Drupal 7 - Loja 2013
A content repository for your PHP application or CMS?
Drupal and the Semantic Web - ESIP Webinar
Getting started with DSpace 7 REST API
Development without Constraint
GraphQL is actually rest
The Future of Search and SEO in Drupal
Hacktoberfest 2020 - Intro to Knowledge Graphs
NoSQL
MongoDB Basics
Devoxx 2008 - REST in Peace
A Deep Dive into RESTful API Design Part 2
Slides semantic web and Drupal 7 NYCCamp 2012
Pragmatic REST APIs
Drupal and the semantic web - SemTechBiz 2012
Java Web Services [5/5]: REST and JAX-RS
Intro to Hypermedia APIs
Restful webservice
Real time semantic search engine for social tv streams
Ad

More from Python Ireland (20)

PDF
Async I/O in Python
PDF
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
PDF
Python Ireland - Who, how, what
PPT
Object Orientation vs. Functional Programming in Python
PDF
What's the Scoop with Python 3?
PDF
Google App Engine in 40 minutes (the absolute essentials)
PDF
Introduction to Erlang for Python Programmers
PPT
Web-service based Mobile Geospatial Application Development using Python
PDF
Utopia Kingdoms scaling case. From 4 users to 50.000+
PPT
The Larch - a visual interactive programming environment
PDF
Python vs JLizard.... a python logging experience
PDF
Vim and Python
PDF
Python Ireland Nov 2009 Talk - Appengine
ODP
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
PDF
Python Ireland Nov 2010 Talk: Unit Testing
ODP
Python Ireland Feb '11 Talks: Introduction to Python
PPTX
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
PDF
KEY
Python for cloud computing
ODP
IPython: The awesome python shell
Async I/O in Python
Python Ireland 2012 - Message brokers and Python by Fernando Ciciliati
Python Ireland - Who, how, what
Object Orientation vs. Functional Programming in Python
What's the Scoop with Python 3?
Google App Engine in 40 minutes (the absolute essentials)
Introduction to Erlang for Python Programmers
Web-service based Mobile Geospatial Application Development using Python
Utopia Kingdoms scaling case. From 4 users to 50.000+
The Larch - a visual interactive programming environment
Python vs JLizard.... a python logging experience
Vim and Python
Python Ireland Nov 2009 Talk - Appengine
Python Ireland May 2011 - What is Pyramid and where is it with respect to Dja...
Python Ireland Nov 2010 Talk: Unit Testing
Python Ireland Feb '11 Talks: Introduction to Python
Python Ireland Dec Talks - Windows Azure -- The Nuts and Bolts
Python for cloud computing
IPython: The awesome python shell
Ad

Recently uploaded (20)

PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
REPORT: Heating appliances market in Poland 2024
PDF
Advanced Soft Computing BINUS July 2025.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Smarter Business Operations Powered by IoT Remote Monitoring
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Omni-Path Integration Expertise Offered by Nor-Tech
PPTX
CroxyProxy Instagram Access id login.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
SAP855240_ALP - Defining the Global Template PUBLIC.pdf
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Understanding_Digital_Forensics_Presentation.pptx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
cuic standard and advanced reporting.pdf
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
REPORT: Heating appliances market in Poland 2024
Advanced Soft Computing BINUS July 2025.pdf
MYSQL Presentation for SQL database connectivity
Smarter Business Operations Powered by IoT Remote Monitoring
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Omni-Path Integration Expertise Offered by Nor-Tech
CroxyProxy Instagram Access id login.pptx
NewMind AI Weekly Chronicles - August'25 Week I
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
SAP855240_ALP - Defining the Global Template PUBLIC.pdf
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....

Python Ireland Nov 2010 - RESTing with Django

  • 1. RESTing with DJANGO Fernando Ciciliati Python Ireland November Meet-up 10/11/2010 – The Science Gallery – Dublin
  • 2. Contents ● Quick review of REST ? ● Even quicker review of Django ? ● Let's REST with Django...
  • 4. Practical REST ● Building a web for computers ● They (computers) want to find 'computer-friendly' pages ● They love well organised data/information ● They don't mind about ”visual appeal” ● Side note: There is no ”Google” for them [yet].
  • 5. REST Keywords ● Resource ● ”Resource name” or URI [or URL] ● Representation ● Methods/Verbs (Uniform Interface) ● Links
  • 6. REST: Resource ● Any entity, object or concept we want our application to keep information about ● Obvious resources: ● Books, people, employees, cities, blog entries, bank accounts, hotels, flights, .. ● Slightly less obvious: ● Money transfers, hotel reservations, flight tickets, … ● Even less obvious: ● User session, transaction, ...
  • 7. REST: Resource Name ● Every resource should receive at least one name that identifies it uniquely in its context of usage or existence – ideally, in the world. ● This name should be durable, persistent. ● Typical naming schemas: URLs, URIs, URNs ● It is OK to have more than one name identifying the same resource
  • 8. REST: Representation ● Representations are the materialization, in bytes and bits, of resources. ● Resources are ideas, concepts; representations are ”physical”, ”tangible” REPRESENTATIONS of ideas ● Multiple formats possible ● A single resource can have multiple representations associated to it
  • 9. REST: Uniform Interface ● Minimize number of ”verbs” ● REST x ”WebServices” ● Stick to HTTP verbs
  • 10. Core REST principles ● Addressability ● State and statelessness ● Conectedness ● Uniform Interface ● Safety and Idempotence
  • 11. HTTP ● HTTP is your best friend ● Requests ● Headers ● Body ● Status (return) codes ● 2xx – Success ● 3xx – ??? ● 4xx – ??? ● 5xx – Server Error
  • 13. General Approach urls.py urls.py JSON HTML views.py views.py models.py models.py templates
  • 14. Methods ● OPTIONS ● Should be always available with any URI ● Returns a list of available methods for that URI in the ”Allow” header of the HTTP response; ● GET ● on a collection URI returns a list of items in that collection – for large collections, consider paging ● on an item's URI returns a representation of that item (resource) ● ”Safe”
  • 15. Methods (contd.) ● POST ● Points to a collection URI ● Creates a new resource in that collection ● We don't know the resource-id beforehand ● Not idempotent! ● PUT ● Points to an item URI ● We KNOW the resource-id ● Creates a new resource or updated an existing one ● Idempotent
  • 16. Methods (contd.) ● DELETE ● Usually points to a resouce URI ● Deletes the resource ● Retry strategy is not a problem ● HEAD ● Like GET, but returns only headers, no body ● Good for retrieving information about the resource as its size, language, content type, etc., without transmitting the entire resource.
  • 17. Recommended Tools ● Firefox 3.x ● FireBug (Net tab) or HTTPFox ● Poster ● SQLite Manager ● JSONView ● Modify Headers ● Wireshark
  • 18. Recommended Books RESTful Web Services, Leonard Pro Django, Marty Alchin, Apress Richardson & Sam Ruby, O'Reilly