Hi Ramiro,

Thanks for tip. Setting

DEFAULT_CHARSET = "UTF-8"
FILE_CHARSET = "UTF-8"

did the trick, though I thought it is UTF-8 by default and doesn't
have to be set explicitly.

Anyway now everything's working. Thanks!


---
Maxim

On Dec 5, 2:17 am, Ramiro Morales <cra...@gmail.com> wrote:
> On Sat, Dec 4, 2010 at 3:38 PM, Maxim <smartma...@gmail.com> wrote:
> > Hi,
>
> > I'm trying to write a custom tag that does a very simple action: sets
> > the value into a variable. E.g.
> > {% set variable %}The value{% endset %}
>
> > Here's the essential part of the code (omitting some details):
>
> > def set_tag(parser, token):
> >  nodelist = parser.parse(("endset",))
> >  parser.delete_first_token()
> >  return SetValueNode(arg, nodelist)
>
> > class SetValueNode(template.Node):
> >  def __init__(self, variable, nodelist):
> >    self.variable = variable
> >    self.nodelist = nodelist
>
> >  def render(self, context):
> >    context[self.variable] = self.nodelist.render(context)
> >    return ""
>
> > Everything works great while I'm using ASCII symbols in a template
> > (between set and endset tokens). But once I add UTF-8 symbol I get
>
> > Caught an exception while rendering: ('charmap', u'\u041e
> > \u0442\u0432\u0435\u0442\u044b: ', 0, 6, 'character maps to
> > <undefined>')
>
> > In a trace dump I noticed that this is UnicodeEncodeError, occurring
> > in "self.nodelist.render(context)".
>
> > Any ideas how to deal with it?
>
> The Unicode documentation has specific information
> about custom template elements:
>
> http://docs.djangoproject.com/en/1.2/ref/unicode/#templates
>
> --
> Ramiro Morales

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to