[Answer]-How to display ü created in python and displayed in html?

1👍

With questions like these, it helps if you describe exactly what the error is that you’re seeing.

There are a couple issues with what you’re doing, the biggest being that you’re using strings, not unicode objects.

Here’s the documentation on how to properly create a unicode object in Python

In Python, you can have two different types of strings. One uses only ASCII characters, the other uses any unicode character. You specify a unicode string by surrounding it with a u” instead of ”. Also, by default, Python doesn’t load in your source code as unicode, so you want to encode any strings you have in it (or change the encoding of the file, as shown in the link above) So your line should become:

error = u'F\u00FCllen Sie alle Pflichtfelder aus'

Then everything should work out fine!

After that, as a purely style thing, you probably want to change the last line in your view to just be:

return render_to_response(page.html, {'error':error})

which is effectively the same but a nice shortcut.

0👍

You may try {{ error|safe }} with ü as &uuml. Alternatively save the corresponding .py file as UTF-8 encoded. Hope this leads into the right direction.

👤Jingo

Leave a comment