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
1
vote
2 answers

How to return an object with non-200 status code with django-piston?

In my django-piston handler functions, it looks like I can basically do two things. Either I can return a specific status code with some non-formatted content: def create(...): ... resp = rc.BAD_REQUEST resp.content = 'Some string…
Travis
  • 4,018
  • 4
  • 37
  • 52
1
vote
1 answer

How do I save a Django Model from request.POST?

I'm trying to save a new object from a django model using a POST data querydict. This is part of a PISTON handler. I've seen this done in numerous examples, but I just can't get it to work. Here is my code: class FestHandler(BaseHandler): …
Lyle Pratt
  • 5,636
  • 4
  • 27
  • 28
1
vote
1 answer

Django-Piston - I Can't POST on a model with a ForeignKey

I'm trying to set up piston on my Django project. I ran into a brick wall when I tried to POST (create) a new entry on a model that contains a ForeignKey: location. Here is the exact error I receive: Cannot assign "u'1'": "Fest.location" must be a…
Lyle Pratt
  • 5,636
  • 4
  • 27
  • 28
1
vote
1 answer

How to return a formated error message and the right HTTP code using django-piston?

I would like to be able to return a HTTP Reponse with a formated content with django-piston. I guess I have to create my own rc_factory. What I would like to do is : return rc.404({'status': 0,'message': 'This restaurant does not exists.'}) With a…
Natim
  • 17,274
  • 23
  • 92
  • 150
1
vote
3 answers

django-piston: how to get values of a many to many field?

I have a model with ManyToManyField to another model. I would like to get all the info on a particular record (including the related info from other models) return by JSON. How to get django-piston to display those values? I would be happy with just…
1
vote
2 answers

Making REST calls only available to local applications?

Suppose I have a url like: http://example.com/get-users which returns a JSON object of all users. But, I don't want anyone (or any bots) to be able to go to this url to fetch this information. I want it to only respond to calls from other local…
1
vote
1 answer

(O)Auth with ExtJS

today i tried to get django-piston and ExtJS working. I used the ExtJS restful example and the piston example to create a little restful webapp. Everything works fine except the authentication. Whats the best way to get Basic/Digest/OAuth…
SteffenG
  • 274
  • 2
  • 12
1
vote
1 answer

Django-Piston: ManyToManyField handling?

Bit of a lazyweb question here: anybody know how django-piston handles writes (create/update) to ManyToMany fields?
Parand
  • 102,950
  • 48
  • 151
  • 186
1
vote
1 answer

Django Piston Not Found error

I am using Django 1.5 with Piston. Whenever I try to curl the following url: http://127.0.0.1:8000/search/?limit=20&uri= I get the following error: ["NotFound"] The url pattern: search_resource = Resource(handler=SearchHandler) urlpatterns =…
tank
  • 319
  • 6
  • 15
1
vote
0 answers

Recursion with OneToMany relationship handlers in Django Piston

No matter what I tried, I cannot resolve the recursion with request handlers for my simple OneToMany relationship, let's say Father 1 : N Sons FatherHandler shall return sons_set (list of sons) in it's resultset. SonHandler shall return the father…
Knackling
  • 21
  • 1
1
vote
1 answer

Accessing datetime field in sqlite using python-django

I have a SQLite DB which has few columns of type datetime. These column store time (just the time and not the date) in HH:mm:ss format. When I try to access this field it is returned as null. In models.py this field have been mapped to equivalent…
Haris Farooqui
  • 944
  • 3
  • 12
  • 28
1
vote
1 answer

django piston Circular reference detected while emitting response when using model

Am facing a problem with configuring piston for django, every time I specify the model name it runs I get the below error RuntimeError at /en/vehicle/api/car.json Circular reference detected while emitting response Request Method: GET Request…
Mo J. Mughrabi
  • 6,747
  • 16
  • 85
  • 143
1
vote
1 answer

django-piston method is not allowed

I have this: handlers.py class ChatHandler(BaseHandler): model = ChatMsg allowed_methods = ('POST','GET') def create(self, request, text): message = ChatMsg(user = request.user, text = request.POST['text']) …
LiGhT_WoLF
  • 71
  • 10
1
vote
2 answers

django piston not able to write to rc.BAD_REQUEST

I have django 1.4 and latest piston from pip as of yesterday (I tried to get the version but I didn't know how) Everything seems to be working fine accept when I try to write to the rc.BAD_REQUEST. When I try to return the rc.BAD_REQUEST its working…
Mo J. Mughrabi
  • 6,747
  • 16
  • 85
  • 143
1
vote
1 answer

How to write the django-piston handler to create and return ApiKey?

I'm currently working on the project that use Android for client and Django for web server. I decided to use piston-django to create REST API authentication and I've follow this instruction: What is the right way to write a django-piston client? and…
attomos
  • 1,112
  • 3
  • 16
  • 30