[Answer]-Why can't Django find an object contains unicode like this?

1👍

This part make me think that You are storing not string itself but representation of dict containing this string or json dump of it.

>>> models.Samples.objects.filter(description__contains=u' rosiglitazone / 0.1% DMSO for 1 hour')[0].description
u'{"source name": "3T3-L1 adipocytes (Day 7)", "treatment": "1 \\u03bcM rosiglitazone / 0.1% DMSO for 1 hour", "cell type": "3T3-L1 adipocytes", "chip antibody": "anti-CBP (sc-369; Santa Cruz)"}'

In this case Unicode character will be present in database as \u03bcM but not utf-8 character

To search using this string one should process it same way (json dump or repr)

👤oleg

0👍

I find a hacking to solve this problem

from _json import encode_basestring_ascii as c_encode_basestring_ascii

>>> c_encode_basestring_ascii(a)
'"1 \\u03bcM rosiglitazone / 0.1% DMSO for 1 hour"'

Then the query can return the right result..

Leave a comment