good day! I make a search form html:

<form action='/notebook/search/' method='get'> <input type='text' name='q'> <input type='submit' value='Найти'> </form> 

processing request:

 def note_search(request): """ поиск записи """ if 'q' in request.GET: q = request.GET['q'] notebook = request.user.notebooks.filter(Q(surname=q)) message = 'Вы ищете запись %r' % (request.GET['q']) else: message = 'Строка не должна быть пустой' notebook = request.user.notebooks.all() return render_to_response('notebook.html', {'notebook': notebook, 'message': message}, RequestContext(request)) 

the problem is that later in the {{message}} template is displayed as

 Вы ищете запись u'\u041c\u0430\u043a\u0441' 

but I would like to see

 Вы ищете запись Макс 

because in the search bar I typed the word "Max".

How do I make a readable message output?

    1 answer 1

    You see " u'\u041c\u0430\u043a\u0441' " because this is how the repr that you used, indicating " %r " works.

    Somewhat crutch but it will work fine:

      ... message = u'Вы ищете запись «%s»' % request.GET['q'] else: message = u'Строка не должна быть пустой' ... 

    (The prefixes u - so that everything is cleaner, and byte "strings" are not mixed with Unicode.)

    But it would be more correct, as it seems to me, to transfer this q to the template, and there already display the messages:

     {% if query %} Вы ищете запись «{{ query }}» {% else %} Выведены все записи {% endif %}