[google-appengine] Re: HTML in DB Field and Display in Django Template

2008-11-15 Thread Alexander Kojevnikov

 I have some HTML in a DB field.  How can I get it to display as
 rendered HTML in a Django template.

 Is there a filter or tag that I should use before the {{variable}} tag
 in the Django template?

In Django 0.96 (which is built into appengine) you need to use the
escape filter:

{{ variable|escape }}

In Djange 1.0 all variables are automatically escaped:
http://docs.djangoproject.com/en/dev/topics/templates/#automatic-html-escaping


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: HTML in DB Field and Display in Django Template

2008-11-15 Thread cb

I must still be doing something wrong..

If my stored string is  -   bhello/b

If I include {{item.text}} in my template I get   -bhello/b

and if I include {{item.text|escape}} I get -lt;bgt;hellolt;/
bgt;

but I am trying to achieve a bold hello

On Nov 15, 5:31 pm, Alexander Kojevnikov [EMAIL PROTECTED]
wrote:
  I have some HTML in a DB field.  How can I get it to display as
  rendered HTML in a Django template.

  Is there a filter or tag that I should use before the {{variable}} tag
  in the Django template?

 In Django 0.96 (which is built into appengine) you need to use the
 escape filter:

 {{ variable|escape }}

 In Djange 1.0 all variables are automatically 
 escaped:http://docs.djangoproject.com/en/dev/topics/templates/#automatic-html...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: HTML in DB Field and Display in Django Template

2008-11-15 Thread cb

No,
I am just using the built-in 0.96 templating system and the 'safe'
filter does not work in that version.



On Nov 15, 6:10 pm, Alexander Kojevnikov [EMAIL PROTECTED]
wrote:
  I must still be doing something wrong..

  If my stored string is  -   bhello/b

  If I include {{item.text}} in my template I get   -    bhello/b

  and if I include {{item.text|escape}} I get -    lt;bgt;hellolt;/
  bgt;

  but I am trying to achieve a bold hello

 Are you using Django 1.0?

 It that case you should un-escape with the safe filter:

     {{ item.text|safe }}
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: HTML in DB Field and Display in Django Template

2008-11-15 Thread Alexander Kojevnikov

 No,
 I am just using the built-in 0.96 templating system and the 'safe'
 filter does not work in that version.

Could you post here your template and the code that renders it?

I see two reasons why it doesn't work as expeced:

1. Your html is already escaped in the datastore.
2. Your Content-Type is text/plain instead of text/html.




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---