guys i am having problems creating a new resource with django tastypie. i
get the following error:
class RatingResource(ModelResource):
city = fields.ForeignKey(CityResource, 'city')
user_id = fields.ForeignKey(UserResource, 'user')
class Meta:
queryset = Rating.objects.all()
resource_name = 'rating'
#authentication = BasicAuthentication()
#authorization = DjangoAuthorization()
curl --dump-header - -H "Content-Type: application/json" -X POST --data '{city:
"/api/smarturbia/city/35/", comment: "teste do php", id: "4", resource_uri:
"/api/smarturbia/rating/4/", rating: "3",user_id:
"/api/smarturbia/auth/user/2/"}' http://127.0.0.1:8000/api/smarturbia/rating/
HTTP/1.0 500 INTERNAL SERVER ERROR
Date: Mon, 08 Apr 2013 10:36:34 GMT
Server: WSGIServer/0.1 Python/2.7.3
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
Content-Type: application/json
Access-Control-Allow-Headers: Content-Type,*
Access-Control-Allow-Credentials: true
{"error_message": "Expecting property name: line 1 column 1 (char 1)",
"traceback": "Traceback (most recent call last):\n\n File
\"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 202, in
wrapper\n response = callback(request, *args, **kwargs)\n\n File
\"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 440, in
dispatch_list\n return self.dispatch('list', request, **kwargs)\n\n File
\"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 472, in
dispatch\n response = method(request, **kwargs)\n\n File
\"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 1325, in
post_list\n deserialized = self.deserialize(request, request.raw_post_data,
format=request.META.get('CONTENT_TYPE', 'application/json'))\n\n File
\"/usr/local/lib/python2.7/dist-packages/tastypie/resources.py\", line 389, in
deserialize\n deserialized = self._meta.serializer.deserialize(data,
format=request.META.get('CONTENT_TYPE', 'application/json'))\n\n File
\"/usr/local/lib/python2.7/dist-packages/tastypie/serializers.py\", line 205,
in deserialize\n deserialized = getattr(self, \"from_%s\" %
desired_format)(content)\n\n File
\"/usr/local/lib/python2.7/dist-packages/tastypie/serializers.py\", line 359,
in from_json\n return simplejson.loads(content)\n\n File
\"/usr/lib/python2.7/dist-packages/simplejson/__init__.py\", line 413, in
loads\n return _default_decoder.decode(s)\n\n File
\"/usr/lib/python2.7/dist-packages/simplejson/decoder.py\", line 402, in
decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n\n File
\"/usr/lib/python2.7/dist-packages/simplejson/decoder.py\", line 418, in
raw_decode\n obj, end = self.scan_once(s, idx)\n\nJSONDecodeError: Expecting
property name: line 1 column 1 (char 1)\n"}
any ideas?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.