Я пытаюсь отправить модель Backbone.js как POST в Piston и получаю сообщение об ошибке:
Отчет о сбое Piston / 0.2.2 (Django 1.3):
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/piston/handler.py",
line 81, in create inst = self.model.objects.get(**attrs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py",
line 132, in get return self.get_query_set().get(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py",
line 341, in get clone = self.filter(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py",
line 550, in filter return self._filter_or_exclude(False, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py",
line 568, in _filter_or_exclude clone.query.add_q(Q(*args, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py",
line 1172, in add_q can_reuse=used_aliases, force_having=force_having)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py",
line 1060, in add_filter negate=negate, process_extras=process_extras)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py",
line 1238, in setup_joins "Choices are: %s" % (name, ", ".join(names)))
FieldError: Cannot resolve keyword 'model' into field.
Choices are: calendar, date, id, name, priority
Код:
$(function() {
Backbone.emulateJSON = true;
$('form').submit(function() {
formdict = jsonform($("form#add_task :input"));
var new_task = new Task({
calendar: formdict.calendar,
date: formdict.date,
name: formdict.name,
priority: formdict.priority});
console.log("new _task: " + new_task);
new_task.save();
return false;
});
});
});
Информация об ответе и запросе:
Request URL:http://localhost:8000/api/task/
Request Method:POST
Status Code:500 INTERNAL SERVER ERROR
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:156
Content-Type:application/x-www-form-urlencoded
X-Requested-With:XMLHttpRequest
Form Dataview URL encoded
model:{"date":"2012-03-10T01:12:43.876Z","name":"New event","priority":0,"id":1,"calendar":"null"}
Источник просмотра заголовков ответа
Access-Control-Allow-Headers:Origin,Content-Type,Accept
Access-Control-Allow-Methods:POST,GET,OPTIONS,PUT,DELETE
Access-Control-Allow-Origin:*
Content-Type:text/html; charset=utf-8
Date:Sat, 10 Mar 2012 01:12:44 GMT
Server:WSGIServer/0.1 Python/2.7.2+
Vary:Authorization
Как заставить Piston принять модель?