On Sat, Dec 8, 2012 at 9:14 PM, Tom Christie <
christ...@gmail.com> wrote:
>> At some point django-rest-framework attempts to get something from the
> queryset with id = "", and I get an exception about converting the
> empty string to int.
>
> Okay that was a bug that you'd see in the Browseable API, but not when using
> JSON. Should be fixed in 2.1.8 which is now released.
I see that using JSON, I'll try one more time to make sure.
>> A similar problem appears with the fact that I need to include "id" in
> my "fields". When I post, I need to set that to 0.
>
> I'm not sure I follow that. POST or PUT? Which generic view? When would
> you want to set the id of an object to null?
I'm not trying to POST or PUT null as an id. I have fields = ('id',
...,) in my ModelSerializer, because I want to retrieve the id during
GET requests. But when I do a POST to create a new object, and I omit
the id, rest-framework will raise an exception because the empty
string could not be converted to int, during a .objects.get(id = id)
query.
So I have to resort to setting a fake id = 0 in my POST.
>> I can send a fake date in the request, like ´1970-01-01', because the
> fields are auto_now, but it's inelegant. Got a fix for that too?
>
> The best way to help me out and get it fixed quickly would be to submit a
> failing test case in a pull req.
I'll give it a try soon, unless you have time to look into it first.
Thanks!