background preloader

Django_restful

Facebook Twitter

Consulting » Test Driving a RESTful Django Contribution. This time around, I will try to take the logical next step with my exploration of REST and Django, and begin creating a Django contribution to implement the ideas I have been working on and to do so in a way that fits with Django’s philosophy.

consulting » Test Driving a RESTful Django Contribution

If you would like to get caught up, here are the previous posts in this series: Dugan Chen's Homepage. 'rest' tag wiki. Ajax - How do I check that user already authenticated from tastypie. A Beginner’s Introduction to HTTP and REST. Hypertext Transfer Protocol (HTTP) is the life of the web.

A Beginner’s Introduction to HTTP and REST

It's used every time you transfer a document, or make an AJAX request. But HTTP is surprisingly a relative unknown among some web developers. This introduction will demonstrate how the set of design principles, known as REST, underpin HTTP, and allow you to embrace its fullest power by building interfaces, which can be used from nearly any device or operating system. Republished Tutorial Every few weeks, we revisit some of our reader's favorite posts from throughout the history of the site. Simple REST URIs : blog : Josh Bohde. When talking about REST APIs, one of the frequent questions pertains to the benefits of using an Accept header, rather than file extensions, to do content negotiation.

Simple REST URIs : blog : Josh Bohde

Often, the benefits of the Accept header don’t seem to outweigh the familiarity of file extensions. An Example Application. Learning - What is the proper way to do REST. Apigee’s slideshows on SlideShare. RESTful API Design - Second Edition. Utiliser une architecture RESTful avec Django — Le blog des développeurs de Pilot Systems. Cet article introduit les architectures basées sur REST (Representational State Transfer) dans le cadre du développement d'applications Web et d'APIs avec Django ainsi que les problématiques rencontrées avec les méthodes HTTP PUT et DELETE.

Utiliser une architecture RESTful avec Django — Le blog des développeurs de Pilot Systems

Qu'est-ce que REST ? Une architecture dite RESTful permet d’identifier des ressources (correspondant classiquement à des modèles ou classes d’objets stockés en base de données) accessibles par l’utilisateur, qu'il soit un être humain ou un système informatique, via des URLs et de modifier leur état via des verbes et paramètres de la requête HTTP invoquant cette URL. Chaque URL est reliée à une fonction (qu’on appelle une "vue" dans Django) capable d’effectuer un traitement sur une requête HTTP, puis de renvoyer une réponse HTTP en fonction du verbe et des paramètres HTTP qu’elle a reçus dans la requête initiale. Building RESTful API with Django. ★ Développer une application RESTful avec Django — Biologeek. Après vous avoir expliqué la théorie sur l'architecture REST, rien de vaut un exemple concret pour bien comprendre le mécanisme.

★ Développer une application RESTful avec Django — Biologeek

REST & WOA Wiki - REST & WOA Wiki. RESTFul Design Patterns. Summarize a set of RESTful design practices that I have used quite successfully.

RESTFul Design Patterns

Object PatternsIf there are many objects of the same type, the object URL should contains the id of the object. If this object is a singleton object of that type, the id is not needed. Get the object representationHTTP GET is used to obtain a representation of the object. By default the URI refers to the object's metadata but not actual content. To get the actual content ... HTTP header "Accept" is also used to indicate the expected format. GET /library/books/668102 HTTP/1.1Host: www.xyz.comAccept: application/json Modify an existing ObjectHTTP PUT is used to modify the object, the request body contains the representation of the Object after successful modification. Create a new Object HTTP PUT is also used to create the object if the caller has complete control of assigning the object id, the request body contains the representation of the Object after successful creation.

HTTP/1.1 201 Created. Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009. Using Pushstate with Backbone.js and Django : blog : Josh Bohde. One way to keep the project keeps templates DRY is through a template tag that renders mustache templates inline.

Using Pushstate with Backbone.js and Django : blog : Josh Bohde

Combined with a client side template engine, templates can be shared between the client and server. Example usage: <div class="tweet"> {%mustache "path/to/my/tweetTemplate" tweet%}</div> By using Tastypie Resources in the view, the same data preparation can be used for both methods.

The view from the example project is as follows: Django and backbone.js questions. REST Anti-Patterns. When people start trying out REST, they usually start looking around for examples – and not only find a lot of examples that claim to be “RESTful”, or are labeled as a “REST API”, but also dig up a lot of discussions about why a specific service that claims to do REST actually fails to do so.

REST Anti-Patterns

Why does this happen? HTTP is nothing new, but it has been applied in a wide variety of ways. Some of them were in line with the ideas the Web’s designers had in mind, but many were not. Applying REST principles to your HTTP applications, whether you build them for human consumption, for use by another program, or both, means that you do the exact opposite: You try to use the Web “correctly”, or if you object to the idea that one is “right” and one is “wrong”: in a RESTful way. For many, this is indeed a very new approach.

As with any new approach, it helps to be aware of some common patterns. API Anti-Patterns: How to Avoid Common REST Mistakes. REST worst practices. A few weeks ago, I sent the following in a email to a co-worker asking for input on designing REST APIs in Django.

REST worst practices

Since then, I’ve quoted myself a few times; I thought these thoughts would be worth a (slightly edited) public home. I think the best way to dive in terms of mistakes to avoid. Refactor the Life » Blog Archive » RESTful Django practice. After several rounds reading RESTfull Web Services, I still have feeble confidence on my understanding the hyped REST idea, so please never hesitate to criticize, suggest in the comment.

Refactor the Life » Blog Archive » RESTful Django practice

Expose the resources A book can be easily be identified by ISBN or EAN, however, it may stand for the specific book other than other books, or it refers an eBook instance to for content presentation. A Django Anti-Pattern, Rolling Your Own REST. Last week I got an email from Charlie O'Keefe, and one of the topics it hit upon was the lack of simple support for RESTful apis in Django. I promised a quick blog entry on the topic, but it hasn't really been coming together. The problem is one of a library. Not that there aren't libraries, there are a handful, but none of them have quite hit the sweet spot yet.

I think that the community hasn't been too bothered by this lack because its usually trivial to write the RESTful view you need by hand using just a couple of views.