I had a search form in my forms.py:
class search_form(forms.Form):
text = forms.CharField( widget =
forms.TextInput({ "placeholder": "введите слово" }) )
and my form header is
<form action='/search_results/' method='get'>
Then I'm getting properties from my base
def search_results(request):
context = {}
if request.GET:
form = search_form(request.GET)
if form.is_valid():
print form.cleaned_data['text']
properties = PropertyText.objects.filter(value__icontains =
form.cleaned_data['text'])
If I'm using Latin symbols - I get correct results, but as soon as I'm trying to search for Russian words I fail. For example, I type word для
(it's all over my articles) and I get no results. print form.cleaned_data['text']
returns me some strange symbols ÑÑо
, and so does print request.GET['text']
encode('utf-8')
gives no result, decode('utf-8')
throws an exception 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)
I had # -*- coding: utf-8 -*-
in my views.py, forms.py and urls.py and <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
in my template