Re: Update dict JsonField Postgresql

2017-03-28 Thread Martin Peveri
It does not work :( With ArrayField Will I be able to filter the content of the field?. For example, if i have one record and in the field data a list of dict with 50k. Can I filter it?. That is to say, to bring only in the array the records with 'processed' true. Thanks! El martes, 28 de ma

Re: Update dict JsonField Postgresql

2017-03-28 Thread Melvyn Sopacua
On Monday 27 March 2017 15:03:17 Martin Peveri wrote: > Perfect!! This code works: > > data = objectitem.data > > data[0]['processed'] = True > > objectitem.data = data > > objectitem.save() > > A last query that is not related to the insertion, but to the query. > > If I want to get only rec

Re: Update dict JsonField Postgresql

2017-03-27 Thread Martin Peveri
Perfect!! This code works: data = objectitem.data data[0]['processed'] = True objectitem.data = data objectitem.save() A last query that is not related to the insertion, but to the query. If I want to get only records processed in True as I have to do? This does not work, I get all the recor

Re: Update dict JsonField Postgresql

2017-03-27 Thread Melvyn Sopacua
Hi, On Monday 27 March 2017 08:50:04 Martin Peveri wrote: Totally forgot about this gotcha: > > > >>> objectitem.data[0]['processed'] = True That won't work. objectitem.data is a reference to a list of dicts changing something inside, doesn't signal the model that it's data has changed, as the

Re: Update dict JsonField Postgresql

2017-03-27 Thread Martin Peveri
json.dumps return this (For example, the field contains 50k of records): [{'number': '1160188479', 'id': 0, 'content': 'hello', 'processed': False}, {'number': '1160188479', 'id': 1, 'content': 'hello', 'processed': False}, { 'number': '1160188479', 'id': 2,'content': 'hello', 'processed': False}

Re: Update dict JsonField Postgresql

2017-03-27 Thread Melvyn Sopacua
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 > >

Re: Update dict JsonField Postgresql

2017-03-27 Thread Martin Peveri
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] >>> F

Re: Update dict JsonField Postgresql

2017-03-27 Thread Melvyn Sopacua
On Monday 27 March 2017 05:56:34 Martin Peveri wrote: > But not working. > > Any Idea?. Plenty. But start by defining "not working". Not trying to be snarky, but there are a lot of moving parts here and it's anybody's guess at this point what part is causing the problem. We don't even know how

Update dict JsonField Postgresql

2017-03-27 Thread Martin Peveri
Hi everyone, I have a model model like this: class ItemCampaign(models.Model): campaign = models.ForeignKey( Campaign, related_name="itemscampaign", verbose_name="Item campaƱa" ) data = JSONField(default=dict) def __str__(self): return self.campaign.name The field dat