django-piston

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

对着背影说爱祢 提交于 2020-01-03 02:46:11
问题 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 primary keys. Or can you suggest another option ? 回答1: I may be wrong, but this should do it: class PersonHandler(BaseHandler): model = Person fields = ('id', ('friends', ('id', 'name')), 'name') def read(self, request): return Person.objects

How to prevent 'IOError: failed to write data' when client closes connection to Django/WSGI app?

浪尽此生 提交于 2020-01-01 12:33:13
问题 I have an iPhone app that is using web services implemented in Python, using Django and Piston, running on an apache server through WSGI. Sometimes the app closes its connection to the server before a call is finished. When it does this it causes a: [Tue Sep 06 11:29:46 2011] [error] [client 207.35.164.99] mod_wsgi (pid=820): Exception occurred processing WSGI script 'myscript.wsgi'. [Tue Sep 06 11:29:46 2011] [error] [client 207.35.164.99] IOError: failed to write data to appear in my server

Writing a Two-legged OAuth provider in Django

萝らか妹 提交于 2020-01-01 06:52:08
问题 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... 回答1: '2 legged' is just normal OAuth request without an access token or access token secret. That's it. You still use the client credentials (identifier and secret) but use empty strings for the access token parameters. Depending on the server library you use, you can omit the oauth_token

Running Django-Celery in Production

假装没事ソ 提交于 2020-01-01 04:23:44
问题 I've built a Django web application and some Django-Piston services. Using a web interface a user submits some data which is POSTed to a web service and that web service in turn uses Django-celery to start a background task. Everything works fine in the development environment using manage.py. Now I'm trying to move this to production on a proper apache server. The web application and web services work fine in production but I'm having serious issues starting celeryd as a daemon. Based on

Is Piston ready for OAuth?

本小妞迷上赌 提交于 2019-12-22 08:39:08
问题 I tried using Piston for a simple API, hoping to use its OAuth support. But the first time I hit the endpoint after enabling OAuth, I got an error: TemplateDoesNotExist: oauth/challenge.html and sure enough, there is no such file. Does OAuth work in Piston? Am I making a stupid mistake? 回答1: Nope - that looks like a bug in Piston. oauth/challenge.html is referenced here, but does not exist anywhere in that project (see Piston's templates folder). Could you try creating an empty oauth

How to get day name in datetime in python?

此生再无相见时 提交于 2019-12-17 10:24:18
问题 How can I get the day name (such as: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday) in datetime in python?... Here is my code in my handlers.py from django.utils.xmlutils import SimplerXMLGenerator from piston.handler import BaseHandler from booking.models import * from django.db.models import * from piston.utils import rc, require_mime, require_extended, validate import datetime class BookingHandler(BaseHandler): allowed_method = ('GET', 'POST', 'PUT', 'DELETE') fields =

UnboundLocalError: local variable 'prod_Available' referenced before assignment

十年热恋 提交于 2019-12-13 17:18:32
问题 I am developing a reservation system, and i have a function that save the quantity of a product... My question is why I got this problem ? when i `curl -l -X POST -d "product=3&client=1&function=insert_booking&check_in=2011-12-15&check_out=2011-12-10&no_of_adult=2&no_of_kid=1&quantity=2&first_name=asda&last_name=sdsd&contact=34343" http://127.0.0.1:8000/api/reserve` Piston/0.3dev (Django 1.3.1) crash report: Traceback (most recent call last): File "/home/agileone/workspace/bookproj/api

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

社会主义新天地 提交于 2019-12-13 15:50:29
问题 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 runserver: [16/Nov/2011 00:11:17] "DELETE /api/phonebooks/10 HTTP/1.1" 301 0 [16/Nov/2011 00:11:17] "GET /api/phonebooks/10/ HTTP/1.1" 200 255 [16/Nov/2011 00:11:23] "PUT /api/phonebooks/12 HTTP/1.1" 301 0 [16/Nov/2011 00:11:23] "GET /api

basic http authentication with django-piston

孤人 提交于 2019-12-12 18:41:53
问题 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 django.conf.urls.defaults import * from piston.resource import Resource from piston.authentication import HttpBasicAuthentication from myapp.handlers import BlogPostHandler, ArbitraryDataHandler auth = HttpBasicAuthentication(realm="My Realm") ad = {

Django: custom serialization options?

百般思念 提交于 2019-12-09 06:46:52
问题 I'm working on a Django-based web service and I'm trying to figure out what the best way to do my serialization will be. The tricky requirement, though, is that I'd like to have pretty much full control over format of, and fields contained in, the response. For example, the Django serializers (which, unfortunately, includes the wadofstuff serializer) automatically wrap the fields in { model: "app.Model", pk: 42, fields: { ... }} , which is great for creating fixtures, but isn't great for me —