{% if posts %}
{% for p in posts %}
{{p|safe}}
{% endfor %}
{% endif %}
I want this to render html but not javascript, what should I do?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no filter in
djangothat can do what ou want: strip javascript and leave html.You can create a custom template filter to do that:
(Where to put template filters/tags: Custom template tags and filters/Code layout)
Brief explanation:
Create a folder named
templatetagsin your application folder. Add an empty file__init__.py(for it to be a package) and a module file that will contain the filter,my_filters.py. Copy the code in that file.In the template file add (before any first use of the filter):
{% load my_filters %}Usage: