python - add() argument after * must be a sequence, not Result -
models.py
class result(models.model): host = models.charfield(max_length=200) type = models.charfield(max_length=1, choices=type_choices) active = models.booleanfield(default=false) current = models.floatfield() value = models.floatfield() notify = models.booleanfield(default=false) info = models.textfield() test = models.foreignkey('test', related_name='result') group = models.foreignkey(group, blank=true, null=true, default=none, related_name='result') timestamp = models.datetimefield() created = models.datetimefield(auto_now=true)
my resource:
class resultresource(modelresource): test = fields.foreignkey(testresource, 'test', full=true, related_name='result') group = fields.foreignkey(groupresource, 'group', full=true, related_name='result') class meta: queryset = result.objects.all() list_allowed_methods = ['get', 'post'] resource_name = 'result' fields = ['host', 'type', 'current', 'value', 'notify', 'info', 'timestamp'] include_resource_uri = false excludes = ['id', 'group'] authentication = authentication() authorization = authorization()
i want create new resource via post request.
this json:
{ "current": 26.74, "host": "host 1", "info": "info text", "notify": true, "test": "/api/v1/test/1/", "timestamp": "2010-11-10t03:07:43", "type": "w", "value": 10, "group" : "/api/v1/group/1/" }
the test , group exist.
but error: "error_message": "add() argument after * must sequence, not result".
i read tastypie has problems many2many fields changed, testing, many2many field foreignkey field. doesn't solve problem.
edit: stack trace
file "/home/hschneider/workspace/python/igs/env/local/lib/python2.7/site-packages/tastypie/resources.py", line 217, in wrapper response = callback(request, *args, **kwargs) file "/home/hschneider/workspace/python/igs/env/local/lib/python2.7/site-packages/tastypie/resources.py", line 459, in dispatch_list return self.dispatch('list', request, **kwargs) file "/home/hschneider/workspace/python/igs/env/local/lib/python2.7/site-packages/tastypie/resources.py", line 491, in dispatch response = method(request, **kwargs) file "/home/hschneider/workspace/python/igs/env/local/lib/python2.7/site-packages/tastypie/resources.py", line 1357, in post_list updated_bundle = self.obj_create(bundle, **self.remove_api_resource_names(kwargs)) file "/home/hschneider/workspace/python/igs/env/local/lib/python2.7/site-packages/tastypie/resources.py", line 2150, in obj_create return self.save(bundle) file "/home/hschneider/workspace/python/igs/env/local/lib/python2.7/site-packages/tastypie/resources.py", line 2293, in save self.save_related(bundle) file "/home/hschneider/workspace/python/igs/env/local/lib/python2.7/site-packages/tastypie/resources.py", line 2344, in save_related setattr(related_obj, field_object.related_name, bundle.obj) file "/home/hschneider/workspace/python/igs/env/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 474, in __set__ manager.add(*value) typeerror: add() argument after * must sequence, not result
Comments
Post a Comment