python - django string shows good in terminal but not in template -
i working on message system after have sent reply, tempalte view of mailbody gets put on 1 line, while when print same string in terminal works fine.
the template:
<div> to: {{ mail.to }}<br> from: {{ mail.sender }}<br> {{ mail.view_sent_at }}<br> </div> <div> <br> {{ mail.body }} </div>
my reply body function: (to change body shown replay)
def reply_format(self): message = self.body message = "> " + message message = message.replace("\r\n", "\r\n> ") send_information = "\r\n\r\n> to: %s\r\n> from: %s\r\n> date: %s\r\n>\r\n" % (self.to, self.sender, self.view_sent_at()) message = send_information + message return message
now example mail body looks when save (and how looks in terminal after).
send reply > to: admin > from: admin > date: 12:14 02-06-2014 > > test. > need lines > byebye
when open in template looks like:
to: admin from: admin 12:14 02-06-2014 send reply > to: admin > from: admin > date: 12:14 02-06-2014 > > test. > need lines > byebye
you can use linebreaks filter in template convert newlines appropriate html tags.
Comments
Post a Comment