<?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>Death of a Gremmie &#187; rating</title>
	<atom:link href="http://deathofagremmie.com/tag/rating/feed/" rel="self" type="application/rss+xml" />
	<link>http://deathofagremmie.com</link>
	<description>by Brian Neal</description>
	<lastBuildDate>Wed, 14 Jul 2010 02:31:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Downloads: Uploading Files and Rating System</title>
		<link>http://deathofagremmie.com/2009/01/25/downloads-and-rating-system/</link>
		<comments>http://deathofagremmie.com/2009/01/25/downloads-and-rating-system/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 18:57:28 +0000</pubDate>
		<dc:creator>gremmie</dc:creator>
				<category><![CDATA[SG101 2.0]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[rating]]></category>
		<category><![CDATA[sg101]]></category>

		<guid isPermaLink="false">http://deathofagremmie.com/?p=143</guid>
		<description><![CDATA[I&#8217;m very happy with the progress I&#8217;ve made on the downloads application. Again, this is similar to the Web links application, so it was somewhat familiar ground. Web links was one of the earliest applications I wrote, so this time I tried to do some slightly different things just to compare and contrast. For Web [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m very happy with the progress I&#8217;ve made on the downloads application. Again, this is similar to the Web links application, so it was somewhat familiar ground. Web links was one of the earliest applications I wrote, so this time I tried to do some slightly different things just to compare and contrast. For Web links, I used a base template for all of the Web links related sub-pages. This was primarily so I could include custom CSS in one spot, and build the main Web links navigation and search form in one place. For downloads, I instead used a template tag for this navigation area. I think I like this a little better, as now my views don&#8217;t have to construct and send in a search form to the template. This is tucked away in one spot in my template tag now. I still have to include the CSS on every page, but I don&#8217;t consider that a big deal.</p>
<p>Even though I have upload functionality in a few other places, I still got bit by a few gotchas when dealing with uploaded files. First of all, you have to construct your &lt;form&gt; tag with an additional encoding type attribute:</p>
<pre>&lt;form action="." method="post" <strong>enctype="multipart/form-data"&gt;</strong></pre>
<p>And on the server side, when validating the received POST arguments and files, you must bind the uploaded files to the form:</p>
<pre>f = MyForm(request.POST, request.FILES)</pre>
<p>Even though I&#8217;ve done this before multiple times, and it is clearly documented in the Django docs, I forgot these steps which caused a few minutes of confusion. I guess I am getting cocky now.</p>
<p>The really fun thing I got working is an AJAX style rating system to let people rate downloads. So now I have something similar to the <a href="http://youtube.com">YouTube.com</a> &#8220;star&#8221; rating system. My progress was aided by <a href="http://www.progressive-coding.com/tutorial.php?id=6">this excellent tutorial at progressive-coding.com</a>. The tutorial shows the steps to write the system in vanilla Javascript, then shows how to integrate it with several Javascript frameworks at the end. Since I&#8217;m using <a href="http://jquery.com/">jQuery</a>, I took the ideas there and wrote the whole thing with jQuery in mind, resulting in smaller code. I&#8217;m glad I took the time to study the tutorial and fashion it into my own making, as I learned a great deal by doing it. I was really impressed, again, by how easy jQuery makes these things. I will likely go over what I came up with in greater detail in a future post.</p>
<p>Now that I have this rating system in place, I think I will add a feature to limit the number of votes you can make on an item. I&#8217;m thinking of allowing a user to vote on a download once a week. It is so easy to vote now, just by a single click, that I&#8217;m sure people would be tempted to vote multiple times. I may go add something like this to the polls application too.</p>
]]></content:encoded>
			<wfw:commentRss>http://deathofagremmie.com/2009/01/25/downloads-and-rating-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
