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
1 answer

Simple Django filter query: group by primary key?

I am running a filter query in Django with range. I thought filter always returned a queryset that was grouped by the primary key, but it seems not. These are my models: class MCode(models.Model): code = models.CharField(max_length=16) class…
flossfan
  • 10,554
  • 16
  • 42
  • 53
1
vote
1 answer

handlers error in django-piston

i got a this error in my django project when i implement another handlers for my django-piston. Request Method: GET Request URL: http://127.0.0.1:8000/api/getdata/ Django Version: 1.3.1 Python Version: 2.7.1 Installed…
gadss
  • 21,687
  • 41
  • 104
  • 154
1
vote
1 answer

equivalent CURL for Lua, (Django API Json to Lua Json) POST method

I have a Django that having API for JSON, and I want it to get it in my Lua (Corona SDK) project. if I CURL my Django project. curl -l -X POST -d "message=getstrings" http://127.0.0.1:8000/api/getstrings/ this will return: { "message":…
gadss
  • 21,687
  • 41
  • 104
  • 154
1
vote
1 answer

Limit queryset results based on model field, are there better ways?

basically i want to get the latest 30 log entries for every Host. Currently i'm doing this in django-piston. def read(self,request): val={} for x in Host.objects.all(): …
Harper04
  • 355
  • 2
  • 10
1
vote
1 answer

filter csrfmiddlewaretoken while posting-django

I am planning to make generic CRUD using django-piston. One of my sample code has following class TaskHandler(BaseHandler): allowed_methods = ('GET','POST',) model = Task def read(self, name=None): return self.model.objects.all() def…
sumit
  • 15,003
  • 12
  • 69
  • 110
1
vote
1 answer

Django-piston takes huge response time in read

When returning result from the read method, it takes a huge amount of time to generate/send response (for like 30,000 records with 6 columns, it takes around 14 seconds). Is this fine and it normally takes this much time? If this ins't fine, what…
Sandip Agarwal
  • 1,890
  • 5
  • 28
  • 42
0
votes
2 answers

Cannot resolve keyword 'model' into field. Piston with Backbone.js

I am trying to send a Backbone.js model as a POST to Piston and am getting an error: Piston/0.2.2 (Django 1.3) crash report: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/piston/handler.py", line 81, in create…
user784756
  • 2,363
  • 4
  • 28
  • 44
0
votes
1 answer

Correct way of initializing internal data for API in Django with Piston/Django-tastypie vs jsonrpc

After some API implementations, using jsonrpclib in Python, I need to migrate them inside a Django Framework project. I am quite new in Django and Piston/tastypie, but have some experience using jsonrpc/xmlrpc libs in my Python apps. Until now I…
Luchux
  • 803
  • 1
  • 7
  • 17
0
votes
2 answers

Why use django related REST API packages for non ORM calls?

What are the pros and cons for using django related REST API packages such as tastypie, piston or django-rest for non-ORM calls over simply using views?
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
0
votes
1 answer

Accessing a django-piston REST API via a django view within the same project

I'm building a small web service. To showcase what the service can do I am going to build a lite-weight interface. I'm having a hard time figuring out how my REST API and regular Django views can play nicely together. Here's my setup: Using…
tabdon
  • 157
  • 14
0
votes
2 answers

HTTP POST with XML data does not work in Django-Piston

I have implemented API with django piston in which its take data from sms/mms . For MMS case i have to post XML data with image and others . Here is my code snippet on handlers.py def create(self, request,*args,**kwagrs): try: file_type =…
paul
  • 51
  • 2
  • 11
0
votes
2 answers

Django-piston and UserProfile

I'm using Django-piston and I'd like to get user objects that include user profile data. I'm trying : class UserHandler(BaseHandler): model = User fields = ('id', 'username', 'favorite_color') ... favorite_color is defined in UserProfile…
9-bits
  • 10,395
  • 21
  • 61
  • 83
0
votes
1 answer

Empty docstrings when running django-piston docs under nginx

I'm using django-piston for my REST json api, and I have it all set up for documentation through pistons built in generate_doc function. Under the django runserver, it works great. The template that loops over the doc objects successfully lists the…
jdi
  • 90,542
  • 19
  • 167
  • 203
0
votes
1 answer

How to use Django decorators for Piston handler methods?

Is it possible to use Django (and self-made) view decorators with Piston handler methods? The problem is that with the methods, the first argument is self (the handler) and the second the request, while for the methods the first argument is the…
hupf
  • 604
  • 1
  • 6
  • 10
0
votes
2 answers

how to change xml element name in django-piston?

I'm new with django-piston and whenever i get/post data to xml, the xml's element is always and < resource > 4 0 2011-11-30
gadss
  • 21,687
  • 41
  • 104
  • 154