<?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"
	>

<channel>
	<title>Amit Chakradeo Inc. &#187; django</title>
	<atom:link href="http://amit.chakradeo.net/category/django/feed" rel="self" type="application/rss+xml" />
	<link>http://amit.chakradeo.net</link>
	<description>Stay Hungry. Stay Foolish!</description>
	<pubDate>Wed, 23 Jul 2008 14:03:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>django unicode integration: fix for venus djando template</title>
		<link>http://amit.chakradeo.net/2007/07/05/django-unicode-integration-fix-for-venus-djando-template/</link>
		<comments>http://amit.chakradeo.net/2007/07/05/django-unicode-integration-fix-for-venus-djando-template/#comments</comments>
		<pubDate>Thu, 05 Jul 2007 17:36:25 +0000</pubDate>
		<dc:creator>amit</dc:creator>
		
		<category><![CDATA[Internet]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[webdev]]></category>

		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://amit.chakradeo.net/2007/07/05/django-unicode-integration-fix-for-venus-djando-template/</guid>
		<description><![CDATA[I just upgraded django tree which recently merged in the unicode support. This immediately broke django templates for venus. Here is what you need to change in planet/shell/dj.py to account for new django changes:
43c43,46
< f.write(t.render(context))
---
>         ss = t.render(context)
>         if [...]]]></description>
			<content:encoded><![CDATA[<p>I just upgraded <a href="http://www.djangoproject.com/">django </a>tree which recently merged in the unicode support. This immediately broke <a href="http://www.intertwingly.net/blog/2007/02/14/Django-templates-in-Venus">django templates for venus</a>. Here is what you need to change in planet/shell/dj.py to account for new django changes:</p>
<p>43c43,46<br />
< f.write(t.render(context))<br />
---<br />
>         ss = t.render(context)<br />
>         if isinstance(ss,unicode):<br />
>             ss=ss.encode(&#8217;utf-8&#8242;)<br />
>         f.write(ss)</p>
<p>This is probably due to render returning unicode strings which need to be converted to byte-streams.</p>
<p><strong>Update</strong>: I found out that my changes broke it for people using older version of django. I have updated the patch above to account for that.</p>
]]></content:encoded>
			<wfw:commentRss>http://amit.chakradeo.net/2007/07/05/django-unicode-integration-fix-for-venus-djando-template/feed/</wfw:commentRss>
		</item>
		<item>
		<title>django queryset weirdness</title>
		<link>http://amit.chakradeo.net/2007/04/09/django-queryset-weirdness/</link>
		<comments>http://amit.chakradeo.net/2007/04/09/django-queryset-weirdness/#comments</comments>
		<pubDate>Mon, 09 Apr 2007 17:53:20 +0000</pubDate>
		<dc:creator>amit</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://amit.chakradeo.net/2007/04/09/django-queryset-weirdness/</guid>
		<description><![CDATA[I needed to reset the django admin password and found this page which tells us how to do this. It did not work for me, however I tried to get the user object explicitly, reset the password and save it and it worked!
Here is a session describing the behavior:

> python manage.py shell
In [1]: from django.contrib.auth.models [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to reset the <a href="http://www.djangoproject.com/">django </a>admin password and found <a href="http://coderseye.com/2007/howto-reset-the-admin-password-in-django.html">this page </a>which tells us how to do this. It did not work for me, however I tried to get the user object explicitly, reset the password and save it and it worked!<br />
Here is a session describing the behavior:<br />
<code><br />
> python manage.py shell<br />
In [1]: from django.contrib.auth.models import User<br />
In [2]: u=User.objects.all()<br />
In [3]: u[0].password<br />
Out[3]: &#8217;sha1$0913d$6c5cfefb89b3c77dc8573e466a943c7acd177f6b&#8217;<br />
In [9]: u[0].set_password(&#8217;testme&#8217;)<br />
In [10]: u[0].save()<br />
In [11]: u[0].password<br />
Out[11]: &#8217;sha1$0913d$6c5cfefb89b3c77dc8573e466a943c7acd177f6b&#8217;<br />
In [12]: q=User.objects.get(id=1)<br />
In [13]: q<br />
Out[13]: &lt;user : root&gt;<br />
In [14]: q.set_password(&#8217;testme&#8217;)<br />
In [15]: q.save()<br />
In [16]: q.password<br />
Out[16]: &#8217;sha1$24e9c$868ff39f08c3bde96397e33ea6a8847a658a16bc&#8217;<br />
</code></p>
<p>Maybe this is related to <a href="http://www.djangoproject.com/documentation/db-api/#id3">queryset caching</a>, which would print the same password even after calling set_password. But it looks like in the first method, the password does not even get written to the database. This might be a bug. I will need to run more tests and report (or possibly patch) it&#8230;</p>
<p><strong>Update: </strong>Perhaps I am not clear in the above post. The weirdness is that in the above two scenarios u[0] and q should essentially reference the same user object, but calling set_password (and later save) method on the u[0] reference does not seem to work (i.e. the password attribute remains unchanged and changed password cannot be used on the admin pages) but calling the same method on q reference seems to work! </p>
<p><strong>Update2:</strong>I got it finally. Thanks all (Esp SmileyChris) ! every array slice is a new query! so in the first solution, I need this to make it work:<br />
<code><br />
u=User.objects.all()<br />
u[0].password # to display current hash (Query #1)<br />
q=u[0] # (Query #2)<br />
q.set_password(&#8217;testme&#8217;)<br />
q.save()<br />
q.password<br />
u[0].password # (Query #3) this should print updated hash!</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://amit.chakradeo.net/2007/04/09/django-queryset-weirdness/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Django middleware</title>
		<link>http://amit.chakradeo.net/2005/07/28/django-middleware/</link>
		<comments>http://amit.chakradeo.net/2005/07/28/django-middleware/#comments</comments>
		<pubDate>Fri, 29 Jul 2005 01:18:56 +0000</pubDate>
		<dc:creator>amit</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Scripting]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://amit.chakradeo.net/2005/07/28/django-middleware/</guid>
		<description><![CDATA[In the django project settings there is a key called MIDDLEWARE_CLASSES which is a tuple of strings implementing the middleware methods. Django base handler (TBD explain what this class does) reads this setting and initializes three of its own attributes: _request_middleware, _view_middleware and _response_middleware. It goes through the list of middleware classes instantiates each of [...]]]></description>
			<content:encoded><![CDATA[<p>In the django project settings there is a key called MIDDLEWARE_CLASSES which is a tuple of strings implementing the middleware methods. Django base handler (TBD explain what this class does) reads this setting and initializes three of its own attributes: _request_middleware, _view_middleware and _response_middleware. It goes through the list of middleware classes instantiates each of them and adds the bound method process_request to the _request_middleware attribute, process_view method to view_middleware and process_reponse method to _response middleware.</p>
<p>If the middleware class method returns something (indicating that it has taken some action), the basehandler get_response method returns immediately. Otherwise it proceeds further.</p>
<p>There are 4 middleware classes built in:</p>
<ul>
<li>AdminUserRequired middleware class implements the process_view method and silently returns if the user in the request is logged in and is a valid admin user. Otherwise it returns login page with appropriate error message.</li>
<li>CommonMiddleware implements process_view and process_response methods. process_view rejects forbidden user-agents and prepends URL with www and appends trailing slash if desired. process_response checks if there is a matching flat file present that can be sent for 404&#8217;s and can also send email note to managers about broken links. process_response also manages <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19">ETags</a>
</li>
<li>CacheMiddleware implements process_request to check pages (not containing any query string) against cache. process_response adds pages to cache as needed.</li>
<li>XViewMiddleware (used internally for documentation) implements process_view and attaches &#8216;X-View&#8217; header to internal HEAD requests.</li>
</ul>
<p>Update: 10/14/2005. There are some updates to the middleware that ships with django and is now &#8220;officially&#8221; <a href="http://www.djangoproject.com/documentation/middleware/">documented here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://amit.chakradeo.net/2005/07/28/django-middleware/feed/</wfw:commentRss>
		</item>
		<item>
		<title>django decorators</title>
		<link>http://amit.chakradeo.net/2005/07/28/django-decorators/</link>
		<comments>http://amit.chakradeo.net/2005/07/28/django-decorators/#comments</comments>
		<pubDate>Fri, 29 Jul 2005 00:30:41 +0000</pubDate>
		<dc:creator>amit</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://amit.chakradeo.net/2005/07/28/django-decorator/</guid>
		<description><![CDATA[Django framework has used some design patterns. There is a directory called decorator which currently has two decorators: (decorator is just a method which dynamically adds additional functionality to original method depending on the situation)

funcA = login_required(funcA)
This replaces the funcA with a function which checks if the user is logged in and calls original function [...]]]></description>
			<content:encoded><![CDATA[<p>Django framework has used some design patterns. There is a directory called decorator which currently has two decorators: (<a href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator </a>is just a method which dynamically adds additional functionality to original method depending on the situation)</p>
<ul>
<li><code>funcA = login_required(funcA)</code><br />
This replaces the funcA with a function which checks if the user is logged in and calls original function if the user is indeed logged in and redirects the anonymous users to login page.</li>
<li><code>funcB=cache_page(funcB,cache_timeout,key_prefix)</code><br />
The original function is changed to look into the cached pages.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://amit.chakradeo.net/2005/07/28/django-decorators/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting to know the django web framework</title>
		<link>http://amit.chakradeo.net/2005/07/28/getting-to-know-the-django-web-framework/</link>
		<comments>http://amit.chakradeo.net/2005/07/28/getting-to-know-the-django-web-framework/#comments</comments>
		<pubDate>Thu, 28 Jul 2005 23:42:05 +0000</pubDate>
		<dc:creator>amit</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Python]]></category>

		<category><![CDATA[Scripting]]></category>

		<category><![CDATA[django]]></category>

		<category><![CDATA[webdev]]></category>

		<guid isPermaLink="false">http://amit.chakradeo.net/2005/07/28/getting-to-know-the-django-web-framework/</guid>
		<description><![CDATA[I was just about to abandon python  and join the ruby  camp to be able to use the wonderful rails framework for web application development. (They do have very good documentation and impressive video demo which you should check out!)  But then came the announcement of Django. I really like the python [...]]]></description>
			<content:encoded><![CDATA[<p>I was just about to abandon <a href="http://python.org/">python </a> and join the <a href="http://ruby-lang.org/en/">ruby </a> camp to be able to use the wonderful <a href="http://www.rubyonrails.com/">rails framework</a> for web application development. (They do have very good documentation and <a href="http://www.rubyonrails.com/media/video/rails_take2_with_sound.mov">impressive video demo </a>which you should check out!)  But then came the announcement of <a href="http://www.djangoproject.com/">Django</a>. I really like the python language and feel that I can understand someone else&#8217;s python code, (though ruby looks equally fascinating). I read through the tutorials and checked out the svn repository and worked with the tutorials. This framework looks easy to use and seemingly makes your application portable enough to use any of the underlying database backends (postgresql, mysql, sqlite) and webservers (apache, lighthttpd, twistedweb etc). The initial few days after the announcement, there were very hectic updates on the code and documentation front (with support for sqlite backend , standalone server and new tutorial and documentation about generic views and form fields coming in a matter of a couple of days). This has now gradually slowed down.</p>
<p>I decided to write a sample application (rebate tracking) and immediately hit some issues. I am trying to make the user registration and login/logout part work, but am not following how that is hooked into the framework. The users added with admin interface do not get recognized by the authentication code. Tried IRC help, but haven&#8217;t been able to get anyone who can help. I am studying the code right now. I am going to look closely into the decorator and middleware code now. I will write about my progress here.</p>
]]></content:encoded>
			<wfw:commentRss>http://amit.chakradeo.net/2005/07/28/getting-to-know-the-django-web-framework/feed/</wfw:commentRss>
<enclosure url="http://www.rubyonrails.com/media/video/rails_take2_with_sound.mov" length="54364199" type="video/quicktime" />
		</item>
	</channel>
</rss>
