How to get JOSN Field key value using values()

32 views
Skip to first unread message

Mallik Sai

unread,
Jun 8, 2017, 7:15:08 AM6/8/17
to Django users
I have a JSON Field in my model and I want to get a particular Key value which is present in the JSON Field using values().

lets assume my JOSN Field data is like { 'key1':value1 , 'key2':value2 ,'key3':value3 }

I want to give the query like MyModel.objects.values('field1' , 'field2' , 'key2(which is present in Json Field)')

Please help me whether I can get in using values() or How can I override the values() functionality

pradam programmer

unread,
Jun 8, 2017, 9:22:45 AM6/8/17
to django...@googlegroups.com
Hi Mallik,
Write a Custom Method to do it.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/127677de-e547-47cc-802f-9c59b5ebf839%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mallik Sai

unread,
Jun 9, 2017, 2:38:02 AM6/9/17
to Django users
I have written a custom ActiveQuerySet method for it.
You can find the solution in the following link which works for simple JSON structure.
Reply all
Reply to author
Forward
0 new messages