-
Install django-srcdoc from PyPI:
pip install django-srcdoc -
Add django-srcdoc to
INSTALLED_APPSin yoursettings.py:INSTALLED_APPS = [ # ... 'django_srcdoc', # ... ]
After installation, use the {% srcdoc %} tag much like the {% filter %} tag. A brief example:
<iframe srcdoc="{% srcdoc %}{{ some_html_from_your_project }}{% endsrcdoc %}"></iframe>HTML to be escaped could be written by hand, passed in as a variable, or added with an {% include %} tag (or any other method you like).
The tag will escape HTML per the iframe specification.
django-srcdoc is distributed under the terms of the MIT license.