<?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; array</title>
	<atom:link href="http://www.djangofoo.com/tag/array/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>Session array/list append does not work</title>
		<link>http://www.djangofoo.com/57/session-arraylist-append-does-not-work</link>
		<comments>http://www.djangofoo.com/57/session-arraylist-append-does-not-work#comments</comments>
		<pubDate>Mon, 01 Feb 2010 20:19:52 +0000</pubDate>
		<dc:creator>Davo</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[append]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.djangofoo.com/?p=57</guid>
		<description><![CDATA[I was trying to save and update some arrays inside the Django session object but it was not working at all&#8230; The following snippet DOES NOT WORK request.session['array'] = [] # let's create an empty array # try to append some integers... request.session['array'].append(1) request.session['array'].append(2) request.session['array'].append(3) ... In order to solve this we need to store [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to save and update some arrays inside the Django <strong>session</strong> object but it was not working at all&#8230;</p>
<p>The following snippet <strong>DOES NOT WORK</strong></p>
<pre class="brush: python">
request.session['array'] = [] # let's create an empty array
# try to append some integers...
request.session['array'].append(1)
request.session['array'].append(2)
request.session['array'].append(3)
...
</pre>
<p>In order to solve this we need to store the array in a temporary object first.<br />
Quick fix:</p>
<pre class="brush: python">
request.session['array'] = []
tmp = request.session['array']
tmp.append(1)
tmp.append(2)
tmp.append(3)
request.session['array'] = tmp # this works now.
...
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.djangofoo.com/57/session-arraylist-append-does-not-work/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

