Eran Kampf
Eran Kampf

Reputation: 8986

django Unicode GET Parameter Values

I'm trying to get a GET parameter value that looks like this: http://someurl/handler.json?&q=%E1%F8%E0%F1%F8%E9

The q parameter in this case is Hebrew. I'm trying to read the value using the following code:

request.GET.get("q", None)

I'm getting gybrish instead of the correct text. Any idea what's wrong here? Am I missing some setting?

Upvotes: 1

Views: 2876

Answers (1)

Lukáš Lalinský
Lukáš Lalinský

Reputation: 41306

The query string is in ISO-8859-8, but Django's default encoding is UTF-8. You will have to change either DEFAULT_CHARSET or HttpRequest.encoding to ISO-8859-8 to get the correct Unicode data.

Upvotes: 3

Related Questions