Try the following:
$.put('/my/api/model/someobject/42/', { some_field: 'None' });
I had a similar problem when I tried to filter out some objects on a null foreign key and was able to get them using GET:
http://localhost:8000/api/v1/page/?format=json&next_page=None
Update:
While I was able to get the corresponding objects, passing "No", it does not work for PUT. I was able to update the foreign key field to None with this call:
$.ajax('/api/v1/page/1/',{ contentType: 'application/json', type: 'put', data: JSON.stringify({"next_page": null}) });
I assume this reduces the problem by passing null as application/json
. You can probably pass null as application/x-www-form-urlencoded
, but I don't know how to do this.
By the way, application/json
tabs the default encoding, while application/x-www-form-urlencoded
is the jquery encoding, and some other (all?) Libraries use for ajax. It may be easier to work with json encoding by default tastypie.
source share