开发者

django list of unicode string to pure string

开发者 https://www.devze.com 2023-04-04 13:41 出处:网络
I\'m using Django and Python unicode_countries = request.POST.getlist(u\'countries\') Returns [u开发者_高级运维\'ai\', u\'ag\', u\'aw\', u\'bs\']

I'm using Django and Python

unicode_countries = request.POST.getlist(u'countries')
Returns [u开发者_高级运维'ai', u'ag', u'aw', u'bs']

My goals it to convert unicode_countries to MySQL IN string, which should look like 'ai', 'ag', 'aw', 'bs' which I will use in a MySQL statement as "WHERE countries in ('ai', 'ag', 'aw', 'bs')"

Please help.


No conversion needed.

MyModel.objects.filter(countries__in=unicode_countries)
0

精彩评论

暂无评论...
验证码 换一张
取 消