arc
arc

Reputation: 133

django list of unicode string to pure string

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.

Upvotes: 0

Views: 212

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599610

No conversion needed.

MyModel.objects.filter(countries__in=unicode_countries)

Upvotes: 1

Related Questions