On Mon, 2009-04-20 at 09:47 -0700, NoviceSortOf wrote:
> By digging around here in this group I found
> an answer in using ....
>
> {{ book.description|safe }}
>
It's just a minor thing, since you said this content comes from data
entry, but this allows all HTML in book.description to be displayed,
including potentially unsafe elements (<script> etc).
It might be worth adjusting data entry to just record new lines, and
then use the linebreaksbr filter instead, or if that is too much
effort/a closed system, write an adaptor method to convert the <br> tags
in book.description to newlines, and then use the linebreaksbr filter on
that instead.
Eg in your model:
class Book(Model):
...
def web_description(self):
return self.description.replace('<br>', '\n')
and then in your template:
{{ book.web_description|linebreaksbr }}
Cheers
Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---