Hi devs, Any update on this? Would like to know your thoughts
Thanks, Mani On Sun, Oct 28, 2018 at 1:28 AM Mani S <manikandanc...@gmail.com> wrote: > Django's F objects does not perform JSON lookups. A ticket has been raised > for the same https://code.djangoproject.com/ticket/29769 > > I have written a customer expression for querying JSONField and > * it works!* > > class KeyTextTransformFactory: > > def __init__(self, key_name): > self.key_name = key_name > > def __call__(self, *args, **kwargs): > return KeyTextTransform(self.key_name, *args, **kwargs) > > class JSONF(F): > > def resolve_expression(self, query=None, allow_joins=True, reuse=None, > summarize=False, for_save=False): > rhs = super().resolve_expression(query, allow_joins, reuse, > summarize, for_save) > > field_list = self.name.split(LOOKUP_SEP) > for name in field_list[1:]: > rhs = KeyTextTransformFactory(name)(rhs) > return rhs > > It is necessary to include Cast in rhs, > Sample.objects.filter(jsonfield__lookup__value=Cast(JSONF('value'), > IntegerField())) > > > Comment ref: https://code.djangoproject.com/ticket/29769#comment:5 > > > Note: This is my first contribution in Django source code, any > comments/suggestions would help me learn the process better. > > > > > > Thank you, > Mani > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at https://groups.google.com/group/django-developers. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/88f52ca0-ebd9-4139-b88e-9f21292b7603%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/88f52ca0-ebd9-4139-b88e-9f21292b7603%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMRk_KbkxayLiY8Zv_SJNNfBvQajmDoSKZwWQFc_YQyZGnj9yA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.