0

How convert u'[<Car: { surname :yass name : zazadz } >] in [<Car: { surname :yass name : zazadz } >].

So how convert unicode in django.db.models.query.QuerySet ?

10
  • 1
    out of curiosity, how did you get to that point? Commented Aug 12, 2015 at 12:24
  • One form of my page contains this : <input type="hidden" name="rP" value="{{ queryCar }}" />. So I get this value in my view ( request.POST.get("rP","") ) but this value is unicode Commented Aug 12, 2015 at 12:26
  • 1
    OK, thank you. Must you keep that page as it is or can you change it? If so, what is the purpose of such field? I am trying to understand if there is a better way around this. Commented Aug 12, 2015 at 12:35
  • My page contains many querysets but these querysets are not all used ! My page contains 3 links, when I click on link I want pass to page specific to this link one qeueryset Commented Aug 12, 2015 at 12:39
  • 2
    You can't output a queryset in a form field and pass it back through http post. HTML doesn't know anything about querysets. You'll need to work out some way of passing a simple value which indicates which queryset you want to use. Commented Aug 12, 2015 at 12:42

1 Answer 1

0

This is the function I wrote to convert unicode into string which i then process according to my need. _in_unicode is the parameter passed to this function, which takes an input of type unicode.

def unicode_to_string(_in_unicode): return unicodedata.normalize('NFKD', _in_unicode).encode('ascii', 'ignore') 

You will have to write a parser to process that string and then convert it into proper format for data processing.

P.S: If you are downvoting, please add comment for the reason.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.