<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Django foo &#187; html</title>
	<atom:link href="http://www.djangofoo.com/tag/html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.djangofoo.com</link>
	<description>Django Tips and Tweaks</description>
	<lastBuildDate>Wed, 18 Aug 2010 09:38:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Strip/Remove HTML tags</title>
		<link>http://www.djangofoo.com/45/strip-remove-html-tags</link>
		<comments>http://www.djangofoo.com/45/strip-remove-html-tags#comments</comments>
		<pubDate>Tue, 26 Jan 2010 17:59:28 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[removetags]]></category>
		<category><![CDATA[strip]]></category>
		<category><![CDATA[strip_tags]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=45</guid>
		<description><![CDATA[To strip/remove HTML tags from an existing string we can use the strip_tags function. # import the strip_tags from django.utils.html import strip_tags # simple string with html inside. html = '&#60;p&#62;paragraph&#60;/p&#62;' print html # will produce: &#60;p&#62;paragraph&#60;/p&#62; stripped = strip_tags(html) print stripped # will produce: paragraph This is also available as a template tag: {{ [...]]]></description>
			<content:encoded><![CDATA[<p>To strip/remove HTML tags from an existing string we can use the <strong>strip_tags</strong> function.</p>
<pre class="brush: python">
# import the strip_tags
from django.utils.html import strip_tags

# simple string with html inside.
html = '&lt;p&gt;paragraph&lt;/p&gt;'
print html # will produce: &lt;p&gt;paragraph&lt;/p&gt;

stripped = strip_tags(html)
print stripped # will produce: paragraph
</pre>
<p>This is also available as a template tag:</p>
<pre class="brush: python">
{{ somevalue|striptags }}
</pre>
<p>If you want to remove only specific tags you need to use the <strong>removetags</strong></p>
<pre class="brush:python">
from django.template.defaultfilters import removetags
html = '&lt;strong&gt;Bold...&lt;/strong&gt;&lt;p&gt;paragraph....&lt;/p&gt;'
stripped = removetags(html, 'strong') # removes the strong only.
stripped2 = removetags(html, 'strong p') # removes the strong AND p tags.
</pre>
<p>Also available in template:</p>
<pre class="brush:python">
{{ value|removetags:"a span"|safe }}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/45/strip-remove-html-tags/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

