Hi Martin,
On Monday 27 March 2017 07:05:38 Martin Peveri wrote:
> Hi Melvyn, With "not working", I mean that it does nothing. For
> example
>
> This line
>
> >>> objectitem.data[0]['processed'] = True
>
> It does not return any errors
>
> This line:
> >>> objectitem.save()
>
> Neither
>
> So when I'm going to get the record back, it returns me the same.
>
> >>> objectitem.data[0]
> >>> False
>
> I would have to return True.
Is this really how you typed it? Because objectitem.data[0] should be a dict or list, but not a boolean.
Could you show the output of:
json.dumps(objectitem.data)
> I explain? My English is not very good.
>
> You can explain a little more this: "Django's JSONEncoder only accepts
> dicts as outermost structure."
I'm not sure it is used for assigning data to the json field. It is used to form a django.http.JSONResponse and to serialize data to JSON, so that was a guess.
> I am inserting a list of dicts. For example:
> >>> Model.objects.create(data={[......my dicts ]}
>
> That's wrong?
Not sure, but as you typed it, it's a set, not a dict (there is no 'key':), so if python thinks any of the lists are identifcal, it'll be missing.
--
Melvyn Sopacua
No comments:
Post a Comment