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 project (apache, mod_wsgi) can't import namespace packages

When installing django-piston from the bitbucket repo with pip, I noticed something weird (first indented line of the output): $ pip install hg+http://bitbucket.org/jespern/django-piston Downloading/unpacking…
eternicode
  • 6,805
  • 4
  • 33
  • 39
2
votes
1 answer

Handling related models in Django for use in Django-Piston

I have setup like so (changed for simplicity) class Author(models.Model) name = models.CharField(max_length=100) ... class Document(models.Model): title = models.CharField(max_length=200) content - models.TextField() author =…
Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161
2
votes
1 answer

Django Piston issue - "oauth_user_auth() takes exactly 1 argument (2 given)"

I am having a few problems setting up Django Piston. I have managed to get as far as generating authentication via the oauth_client.py sample shown here (http://github.com/clemesha/django-piston-oauth-example). When I run "python oauth_client.py" i…
Benjamin Dell
  • 2,841
  • 3
  • 18
  • 12
2
votes
2 answers

How to allow foreignkey set to NULL on handlers django-piston

I am trying to make a Dokumen class which has more than one foreign key, several of which can be set to null. I tried writing the code below, but when it hits the API the error below occurred. class DokumenHandler(BaseHandler): allowed_methods =…
2
votes
1 answer

basic http authentication with django-piston

I'm a newb to this. I've seen the code snippet at the official site (pasted below). The problem is how do I deploy this to the server ? Where do I set the username and password credentials ? In the httpd.conf file for Apache ? from…
eerrtt
  • 39
  • 1
  • 3
2
votes
1 answer

Python connect to django piston

I have a django piston that generates an image and returns it to the person who connected to the url, and I am having a hard time connecting to the address using Python 2.6. This is my code currently: #!/usr/bin/env python import httplib import…
SZman
  • 141
  • 2
  • 12
2
votes
1 answer

Django-piston. How to serialize to JSON objects that are not Model subclasses?

I'm working with django + piston and so far created a few urls that are returning my django models in JSON quite well. I didn't even have to specify an emitter, the JSON serialization is done automagically. Now I need to return a JSON serialized…
Mariano
  • 91
  • 1
  • 1
  • 3
2
votes
3 answers

Using "Content-Type:application/json" to post in curl gives HTTP/1.1 400 BAD REQUEST

When I make a post request using the following curl -i -d "username=rock&password=rock" http://my_VM_IP/api/1.1/json/my_login/ it generates the required response generating a token like this(abridged): HTTP/1.1 200 OK Date: Mon, 22 Oct 2012…
The Recruit
  • 803
  • 3
  • 9
  • 18
2
votes
1 answer

Only GET working in cross domain API request with django-piston

I'm not able to do POST/PUT/DELETE cross-domain request on my API using django-piston, I've CORS enabled using this script (based on this): class CORSResource(Resource): """ Piston Resource to enable CORS. """ # headers sent in all…
djevg
  • 689
  • 1
  • 9
  • 15
2
votes
1 answer

django Piston: How can I define custom methods in a handler?

I have created a handler.py and want to write a method : getBooksForUser(). This method will return me all the books issued by a user. The documentation says : In addition to these, you may define any other methods you want. You can use these…
vaibhav
  • 550
  • 5
  • 20
2
votes
1 answer

REST login with Django social_auth

I've been asked to provide a "Login with Facebook" functionality to an iOS app I am creating. The app connects to a REST api created with Piston, the web application is created with Django and uses social_auth. The application also has a Facebook…
Yoeri
  • 1,876
  • 15
  • 24
2
votes
1 answer

Getting a full stack trace with Django-piston

I just started using django-piston. Usually, in Django, when my views throw an exception (and I'm in DEBUG=True mode), I get a really nice, helpful 500-error page with stack trace. But when my Django-piston enabled views throw an exception instead…
Chris W.
  • 37,583
  • 36
  • 99
  • 136
1
vote
2 answers

local fields list not overriding correctly in Django-piston

Has anyone experience issues with this but in Django-piston that doesn't allow you to override fields already set? https://bitbucket.org/jespern/django-piston/issue/192/object-handler-fields-override-local-field Can anyone help me with a work…
9-bits
  • 10,395
  • 21
  • 61
  • 83
1
vote
2 answers

Piston returns HTML instead of JSON

I'm working with Django and Piston and I created the following Handler: from piston.handler import BaseHandler import datetime import json class NotificationHandler( BaseHandler ): allowed_methods = ('POST',) def create( self, request, token…
JPs
  • 11
  • 2
1
vote
1 answer

Call piston handler in django view function

I'm using django piston to implement my RESTful API. I already implemented an api which is /api/[uuid of user] will give all the information related to uuid of user. However, I also want to implement another api /api/user/username where the…
DB Tsai
  • 1,378
  • 1
  • 13
  • 23