KeyError with Django, Sociable app and accented characters? -


I have problems with the characters that have their pronunciation Django Admin " and Aacute" without encoding my data "Some examples like" "saves example: If im trying to use a word like" canción ", then I would like to save it like this: how and ocute; N , and not canynian

I have my setting: DEFAULT_CHARSET = 'utf-8'

Mysql is in the database: utf8_general_ci

I'm using a friendly app:

  {% load sociable_tags%} {% Get_sociable Facebook TwitThis Google MySpace del.icio.us YahooBuzz url = object.get_absolute_url Title = object.titulo%} {live in the form of {% sociable_links} for the link in {sociable_link%} and  gt; & Lt; / A & gt; {% Endfor%}  

But I am getting an error if my object.titulo (title of the article) is an accent word.

  Traceback: File "C: \ wamp \ bin \ Python26 \ lib \ site-packages \ django \ core \ handlers \ base.py" get_response 100. response = callback (request, * callback_args , ** callback_kwargs) file "C: \ Wamp \ bin \ Python26 \ lib \ site-packages \ django \ views \ generic \ date_based.py" object_detail 366. response = HttpResponse (t.render (c), mimetype = mimetype) File "C: \ wamp \ bin \ Python26 \ lib \ site-packages \ django \ template \ __ init__.py" in render 173. Back Self. _Redder (reference) file "C: \ wamp \ bin \ Python26 \ lib \ site-packages \ django \ template \__ init__" Py "_render 167. Back Self Nodelist.render (reference) file" C: \ wamp \ bin \ Python26 \ lib \ site-packages \ django \ template \ __ init__.py "Provide in 796. bits.append (auto-render_ode (node, reference)) file" C: \ wamp \ bin \ Python26 \ lib \ site -packages \ django \ template \ debug.py "render_nod in E72. Results = node.reader (reference) file" C: \ wamp \ bin \ Python26 \ lib \ site-packages \ django \ template \ loader_tags.py "render 125. Back to the compiled_parent._render (reference) file "C: \ Wamp \ bin \ Python26 \ lib \ site-packages \ django \ template \ __ init__.py" _render 16 7. return self.nodelist.render (reference) file "C: \ wamp \ bin \ Python26 \ lib \ site-package \ django \ template \ __ init__.py" render in 796. bits .append (self.render_node (node , Context)) file "C: \ wamp \ bin \ Python26 \ lib \ site-packages \ django \ template \ debug Py "render_node 72. Results = node.reader (reference) file" c: \ wamp \ bin \ Python26 \ lib \ site-packages \ django \ template \ loader_tags.py "Submission in 62. result = block.nodelist.render (Context) File "C: \ wamp \ bin \ Python26 \ lib \ site-packages \ django \ template \ __ init__.py" Provide 796. bits .append (self.render_node (node, reference)) file "C : \ Wamp \ bin \ Python26 \ lib \ site-packages \ django \ template \ debug.py "render_node" 72. Results = node.reader (reference) file "C: \ wamp \ bin \ Python26 \ lib \ site-packages \ Sociable \ templatetags \ sociable_tags.py "37. 'Link': sociable.genlink (site, * * Self.values), file" C: \ wamp \ bin \ Python26 \ lib \ site -packages \ sociable \ sociable.py "in genlink 20. value ['title'] = quote_plus (kwargs ['title']) File" C: \ wamp \ bin \ Python26 \ lib \ urllib.py "in quote_plus 1228 S = Excerpt (S, Secure + ') file "C: \ wamp \ bin \ Python26 \ lib \ urllib.py" 1222 in the quote. Res = map (safe_map .__ getitem__, s) Exception type: TemplateSyntaxError at / noticia / 2010 / jun / 10 / matan-domingo-paquete-en-la-avenida-san-vicente-de-paul / Exception value: Key error while rendering the rendering: u '\ xfa'  

Thank you!

The problem is that the default urllib.quote_plus implementation of the friendly dragon 2.6 Which is not unicode-safe. They should use the django.utils.http.urlquote_plus of the system, which is unicode-safe.

To answer the second part of your question, if you wanted to actually store the strings saved in your database (which I do not recommend) you can call a method that is There is no python or dragon utility to escape the Unicode to HTML-unit to run in the save mode, although I know, though. A quick Google search will convert many, however still, however, I do not recommend doing this. Django is unicode-safe and it is better to take advantage of this fact!


Comments

Post a Comment