1

I have JSONField in my model with following structure:

{
    "1":
        {
            ...
            "is_disabled": false
        },
    "2":
        {
            ...
            "is_disabled": false
        },
    "3":
        {
            ...
            "is_disabled": false
        }
}

And I have set of pks like:

pk_set = {1, 2}

How can i update "is_disabled" key to true only for pks in pk_set in single query?

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
hungry7
  • 49
  • 1
  • 4
  • Looks like pretty regular python dictionary, what have you tried? – PTomasz Aug 16 '22 at 06:44
  • It's not a regular python dict, it's a JSONField in django models. And i want to create one query rather iterating through pk_set. – hungry7 Aug 16 '22 at 07:19
  • 1
    Oh, if you wanted to do that with single query please include that in your question, because technically you could iterate over every object and then for every dict value in pk set update is_disabled and save – PTomasz Aug 16 '22 at 07:36

0 Answers0