Question: I've got the following error:

> 
> TemplateSyntaxError at
>  /admin/results\_cop/copsegmentresult/
> 
> 
> Caught an exception while rendering:
>  ('ascii', 'ISU European Figure Skating
>  Championships 2009: Senior Ladies
>  Ladies: Short Program - 2. Susanna
>  P\xc3\x96YKI\xc3\x96', 98, 99,
>  'ordinal not in range(128)')
> 
> 
> 

The fragment of the string that won't render is: PÖYKIÖ

What I don't get is why Django is trying to render the string as ASCII, why not UTF-8?

EDIT 1:
-------

I forgot to ask - I'd also quite like to know how to get rid of the error ;)

EDIT 2:
-------

Bobince's answer is correct :) I had something along the lines of:

```
def __unicode__(self):
    return "%s %s" (self.foo, self.bar)

```

Answer: 
I'm guessing you're asking Django to render a byte string. No `u` at the start of this:

```
'ISU European Figure Skating Championships 2009: Senior Ladies Ladies: Short Program - 2. Susanna P\xc3\x96YKI\xc3\x96'

```

So Django is probably trying to encode it to the page's encoding, presumably UTF-8. But byte strings can't be encoded directly; they have to be Unicode strings first. Python itself does this converting step using a default encoding which is typically `ascii`.

```
>>> 'P\xc3\x96YKI\xc3\x96'.encode('utf-8')
UnicodeDecodeError

```

So what you need to do is convert that byte string to a Unicode string yourself by UTF-8-decoding it, before it gets sent to the template. Where has it come from? Usually you should aim to keep all content strings inside your application as Unicode strings.
If anyone is confused by bobince's answer, think of this:

The fields from the model are already in unicode format.

when you have a unicode function like this:

```
def __unicode__(self):
  return "{0}".format(self.field_one)

```

It is actually returning a ASCII string(which means, it will try to convert field\_one to ASCII), if the field\_one contains characters outside of ASCII, you will get the problem as above.

Now consider this unicode function:

```
def __unicode__(self):
      return self.field_one

```

This works fine, because you are returning unicode string directly, no conversion needed.

Lets revisit the first **unicode** function, to make it work, you just need to add `u` to make it a unicode string

```
def __unicode__(self):
      return u"{0}".format(self.field_one)

```