5

I understand that this is a little perverse, but I have a legacy database with some entries as formatted html. I'd like to just push this into my django templates as ASCII and let the browser display it.

Django kindly converts my fields to unicode, and so the browser displays the entire text <p> </p> etc. intact.

I was hoping that there might be a template flag {{ obj.text|ascii }} or something that might fix this for me - does anyone have any ideas? Thanks.

2
  • "Render unicode as ASCII" is rather meaningless. Please change the title to something that better reflects what you're trying to accomplish. Commented Apr 22, 2011 at 0:03
  • This doesn't have anything to do with either unicode or ASCII. Commented Apr 22, 2011 at 18:59

1 Answer 1

8

From http://docs.djangoproject.com/en/dev/ref/templates/builtins/ what you want is:

{{ obj.text|safe }}
Sign up to request clarification or add additional context in comments.

1 Comment

Excellent! Ta muchly. Now why couldn't I find that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.