django - Tastypie - Multiform post with foreign fields -
i'm trying post multiform tastypie.
the django model is:
class message(models.model): recipient = models.foreignkey(user, null=true, related_name='recipient')
the tastypie resource:
class messageresource(multipartresource, baseresource): recipient = fields.toonefield(userresource, 'recipient',full=true)
part of form data:
post /api/message/ http/1.1 host: 127.0.0.1:8286 content-type: multipart/form-data; boundary=boundary+0xabcdefgboundary accept: application/json content-length: 6462 accept-language: en;q=1, fr;q=0.9, de;q=0.8, ja;q=0.7, nl;q=0.6, it;q=0.5 accept-encoding: gzip, deflate connection: keep-alive user-agent: c/1.0 (iphone simulator; ios 6.1; scale/1.00) --boundary+0xabcdefgboundary content-disposition: form-data; name="fetched" 0 --boundary+0xabcdefgboundary content-disposition: form-data; name="recipient[id]" 2 --boundary+0xabcdefgboundary content-disposition: form-data; name="recipient[username]" joe --boundary+0xabcdefgboundary content-disposition: form-data; name="text" test --boundary+0xabcdefgboundary content-disposition: form-data; name="image"; filename="photo.png" content-type: image/png <binary data>
since recipient related object, attributes in brackets. tastypie not recognize related object , post fails.
what missing?
Comments
Post a Comment