Safe tag is working differently for different view.

31 views
Skip to first unread message

sonu kumar

unread,
Oct 27, 2015, 4:29:02 PM10/27/15
to Django users
I am having two views both are extending from same base.html and both of them have loaded same template tags, but one is escaping string using safe and other is not what could be 
Code 

view 1
{% extends 'base.html' %}
{% load inplace_edit mezzanine_tags rating_tags keyword_tags comment_tags nano_tags staticfiles %}
...
{% comments_for object %}
...
view 2
{% extends "base.html" %}
{% load inplace_edit mezzanine_tags comment_tags keyword_tags nano_tags i18n future staticfiles %}
...
{% comments_for blog_post %}
...

view3 (comment.html)
{% load i18n mezzanine_tags comment_tags  nano_tags future %}
...
<div class="comment-description">{{ comment.comment|safe  }}</div>
...

As we can see both view 1 and 2 are using same function so it would be using same template but in view2 safe is working and in view1 it's not working.

What could be the reason for this ?

Collin Anderson

unread,
Nov 5, 2015, 10:18:05 AM11/5/15
to Django users
Hello,

Are you sure they're using the same template? (If you change something does it actually affect both views?)

Is one of the views using mark_safe?

Collin

sonu kumar

unread,
Nov 6, 2015, 7:06:02 AM11/6/15
to Django users
Yeah , I am sure both are using same template. I  am using same template on many pages. On all pages it's working fine. Only on one page question answer it's not working as expected. I couldn't find any solution till now.
Reply all
Reply to author
Forward
0 new messages