Questions tagged [django-piston]

A mini-framework for Django for creating RESTful APIs.

Piston is a relatively small Django application that lets you create application programming interfaces (API) for your sites.

It has several unique features:

  • Ties into Django's internal mechanisms.
  • Supports OAuth out of the box (as well as Basic/Digest or custom auth.)
  • Doesn't require tying to models, allowing arbitrary resources.
  • Speaks JSON, YAML, Python Pickle & XML (and HATEOAS.)
  • Ships with a convenient reusable library in Python
  • Respects and encourages proper use of HTTP (status codes, ...)
  • Has built in (optional) form validation (via Django), throttling, etc.
  • Supports streaming, with a small memory footprint.
  • Stays out of your way.

NB: OAuth ships with piston for now, but you are not required to use it. It simply provides some boilerplate in case you want to use it later (consumer/token models, urls, etc.)

Learn More:

Piston Bitbucket Wiki

Piston Documentation

159 questions
2
votes
1 answer

django Piston Post Request Change strings to lists

I have a simple Django-Piston Handler that creates a new instance of a model and saves it. From the client, I am posting using Javascript Objects and JQuery.post. Upon inspecting the data with Firebug, the post string looks like…
MrOodles
  • 1,856
  • 21
  • 21
2
votes
1 answer

how to assign value in django

I have a problem in subtracting a two values. i just want to be like this a = b - c here is my code in my handlers.py def create(self, request): if not self.has_model(): return rc.NOT_IMPLEMENTED attrs =…
gadss
  • 21,687
  • 41
  • 104
  • 154
2
votes
1 answer

unable to update (PUT) and delete (delete) data in django-piston

i just followed this tutorial and the example is great. http://weblog.mattdorn.com/content/restful-web-apps-with-django-piston-and-ext-js/ but when i create on my own, the add method is ok but the delete and update is not. here is the console of my…
gadss
  • 21,687
  • 41
  • 104
  • 154
2
votes
2 answers

How to show foreign key in django-piston rest output instead of related object data

I use latest django-piston 0.2.3rc1 (but may downgrade if needed). class MaintenanceHandler(CsrfExemptBaseHandler): allowed_methods = ('GET', 'POST', 'PUT', 'DELETE') anonymous = is_anonymous = True model = Maintenance fields =…
2
votes
3 answers

Writing a Two-legged OAuth provider in Django

I'm looking for a tutorial/example/explanation about writing a two-legged provider for OAuth in Django. It's hard to find documentation about a OAuth provider, and even harder about a two-legged system...
Lennart-
  • 519
  • 1
  • 6
  • 19
2
votes
1 answer

Django app freezing with a few concurrent requests

I have a django app without views, I only use it to provide a REST API using django-piston package. Since I have deployed it to amazon-ec2 with mod-wsgi, after some requests it freezes, and the CPU goes to 100% of usage divided by python and httpd…
2
votes
1 answer

django/python - what's the recommended secure way to exchange data between my infrastructure and my customers?

I'm using Django/Postgres and Python for my web site and the background processes. I have hundreds of messages every minute populating my database and I would like to securely allow other customers access their data. My customers use either linux…
avatar
  • 12,087
  • 17
  • 66
  • 82
2
votes
1 answer

Django Piston : Define the priority of the returned elements

Let's take this sample : url(r'^test[/]$', test_handler, { 'emitter_format': 'xml' }), With the following handler : class testHandler(BaseHandler): allowed_methods = ('GET',) def read(self, request): return {'element': 'I want to be…
areski
  • 291
  • 2
  • 6
2
votes
1 answer

How to monitor django-piston API Calls even bad ones

i 'm heavily using django-piston for many of my projects, and i wanted to know if there was any way to monitor calls to a REST API creates using Django-Piston. Any Signals emitted ? or decorators ? and more importantly if anyone cares ? Because if…
Olivier Girardot
  • 4,618
  • 6
  • 28
  • 29
2
votes
1 answer

Error handling in Django-Piston

In Django-Piston, is there a good way to do error handling? (Like returning a 400 status code when the caller omits a required GET parameter, or when the parameters are invalid.)
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
2
votes
2 answers

Uploading files to django-piston with ASIHTTPRequest

I'm trying to POST some JSON and a binary file from an iPhone to a Django server running django-piston using ASIHTTPRequest I know how to get it to work if I am ONLY sending JSON strings, and I know how to make it work if I am ONLY sending a file,…
M. Ryan
  • 6,973
  • 11
  • 52
  • 76
2
votes
2 answers

Django Piston - Is there a login_required decorator? If not, how do we raise errors?

I can't figure out for the life of me how to ensure a user is authenticated in Piston. Here's what I've tried. Login_required decorator in Piston. This doesn't seem to work, so I looked and found authentication in Piston. HTTPBasicAuthentication…
killerbarney
  • 947
  • 10
  • 24
2
votes
4 answers

How do I use Django piston to return a response in text/plain?

I want to NOT serialize anything. I just want to return what is equivalent to HttpResponse(blah)
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080
2
votes
1 answer

Django-Piston returning JSON/Dictionary as text/plain whenever I change the response type

I'm debugging some code written by another programmer that uses django-piston to provide an API that returns Python dictionary objects to the caller via JSON. I'm following the documentation on piston here. I noticed some strange behavior where if I…
Nick Ruiz
  • 1,405
  • 4
  • 18
  • 28
2
votes
2 answers

Requesting Token via Django Piston Throws TypeError Exception

When trying to authenticate via OAuth in Django Piston, the following exception is thrown: Environment: Request Method: GET Request URL:…
Derek Reynolds
  • 3,473
  • 3
  • 25
  • 34