Doing the following queryset:
{{{MyModel.objects.filter(my_json_field__en__unaccent__icontains="text")}}}
does not match the above record, because Django interprets "unaccent"' as
a key to find in the JSON dict, whereas I meant the PostgreSQL
{{{unaccent}}} function.
It seems that {{{ unaccent}}} is only supported on CharField and TextField
for now, but since what I am trying to do is possible in SQL, it might be
made possible as well using the ORM.
Details in this StackOverflow question:
https://stackoverflow.com/questions/73385812/looking-up-value-in-
jsonfield-with-unaccent-and-icontains
.
I am tagging QuerySet.extra because my workaround was to write the SQL
where clause I expected using {{{QuerySet.extra}}}.
--
Ticket URL: <https://code.djangoproject.com/ticket/33935>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> With a JSONField value with the following shape: {{{
> my_object.my_json_field = {"en": "sôme téxt"} }}}
>
> Doing the following queryset:
> {{{MyModel.objects.filter(my_json_field__en__unaccent__icontains="text")}}}
> does not match the above record, because Django interprets "unaccent"' as
> a key to find in the JSON dict, whereas I meant the PostgreSQL
> {{{unaccent}}} function.
>
> It seems that {{{ unaccent}}} is only supported on CharField and
> TextField for now, but since what I am trying to do is possible in SQL,
> it might be made possible as well using the ORM.
>
> Details in this StackOverflow question:
> https://stackoverflow.com/questions/73385812/looking-up-value-in-
> jsonfield-with-unaccent-and-icontains
> .
>
> I am tagging QuerySet.extra because my workaround was to write the SQL
> where clause I expected using {{{QuerySet.extra}}}.
New description:
With a JSONField value with the following shape: {{{
my_object.my_json_field = {"en": "sôme téxt"} }}}
Doing the following queryset:
{{{MyModel.objects.filter(my_json_field__en__unaccent__icontains="text")}}}
does not match the above record, because Django interprets "unaccent"' as
a key to find in the JSON dict, whereas I meant the PostgreSQL
{{{unaccent}}} function.
By comparison, with a CharField,
{{{MyModel.objects.filter(my_char_field__unaccent__icontains="test")}}}
works as expected.
It seems that {{{ unaccent}}} is only supported on CharField and TextField
for now, but since what I am trying to do is possible in SQL, it might be
made possible as well using the ORM.
Details in this StackOverflow question:
https://stackoverflow.com/questions/73385812/looking-up-value-in-
jsonfield-with-unaccent-and-icontains
.
I am tagging QuerySet.extra because my workaround was to write the SQL
where clause I expected using {{{QuerySet.extra}}}.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33935#comment:1>
* status: new => closed
* resolution: => duplicate
Comment:
Duplicate of #26511 (see also #27824 and
[https://code.djangoproject.com/ticket/27824#comment:8 Simon's comment]).
--
Ticket URL: <https://code.djangoproject.com/ticket/33935#comment:2>