<?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>Bill Dawson &#187; django</title>
	<atom:link href="http://www.billdawson.com/category/django/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.billdawson.com</link>
	<description>I blog about blogging, trying to build an online presence, making money, etc.</description>
	<lastBuildDate>Thu, 27 May 2010 13:46:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Django debugging</title>
		<link>http://www.billdawson.com/django-debugging/</link>
		<comments>http://www.billdawson.com/django-debugging/#comments</comments>
		<pubDate>Mon, 26 May 2008 21:01:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://www.billdawson.com/blog/?p=12</guid>
		<description><![CDATA[Spent a while reviewing Simon Willison&#8217;s Debugging Django presentation.  Asserting False to get exception pages and dropping into pdb with set_trace() weren&#8217;t new to me, but pdb.pm() and, most especially, using the test client in an interactive shell were new ideas and very interesting indeed.  Check it out if you don&#8217;t know what I mean [...]]]></description>
			<content:encoded><![CDATA[<p>Spent a while reviewing Simon Willison&#8217;s <a title="Debugging Django (Presentation by Simon Willison)" href="http://simonwillison.net/2008/May/22/debugging/">Debugging Django presentation</a>.  Asserting False to get exception pages and dropping into pdb with set_trace() weren&#8217;t new to me, but pdb.pm() and, most especially, using the test client in an interactive shell were new ideas and very interesting indeed.  Check it out if you don&#8217;t know what I mean and you&#8217;re interested.  It&#8217;s a very useful presentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.billdawson.com/django-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly TWiD yearning satisfied</title>
		<link>http://www.billdawson.com/weekly-twid-yearning-satisfied/</link>
		<comments>http://www.billdawson.com/weekly-twid-yearning-satisfied/#comments</comments>
		<pubDate>Tue, 20 May 2008 12:39:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[twid]]></category>

		<guid isPermaLink="false">http://www.billdawson.com/blog/?p=11</guid>
		<description><![CDATA[I can&#8217;t say enough about the value TWiD has had for me. Because I haven&#8217;t yet had the opportunity to work with Django in a day-to-day professional capacity, it has been easy to let my Django learning slip through the cracks. But with TWiD I have a sure-fire way to keep my interest going week [...]]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t say enough about the value TWiD has had for me. Because I haven&#8217;t yet had the opportunity to work with Django in a day-to-day professional capacity, it has been easy to let my Django learning slip through the cracks. But with TWiD I have a sure-fire way to keep my interest going week after week. Hearing folks like <a href="http://djangopeople.net/empty/" title="Michael Trier">Michael</a> and <a href="http://djangopeople.net/brosner/" title="Brian Rosner">Brian</a> &#8212; and their guests such as <a href="http://djangopeople.net/malcolm/" title="Malcom Tredinnick">Malcolm</a> and <a href="http://djangopeople.net/ericflo/" title="Eric Florenzano">Eric</a> &#8212; motivates me to dig deeper into Django.</p>
<p>A few things stuck out for me in this week&#8217;s episode (<a href="http://blog.michaeltrier.com/2008/5/20/this-week-in-django-23-2008-05-18" title="TWiD 23">TWiD 23</a>):</p>
<ul>
<li>The <a href="http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/views/decorators.py#L50" title="staff_member_required decorator"><code>staff_member_required</code> decorator</a>. Didn&#8217;t know about it.</li>
<li>Discovering <a href="http://jannisleidel.com/" title="Jannis Leidel">Jannis Leidel</a> in Germany.  Check out the things that he is working on.  Very interesting projects.</li>
</ul>
<p>Also, for the first time (and as part of <a href="http://www.billdawson.com/blog/2008/05/15/its-time-for-total-django-immersion/" title="Total Django Immersion">TDI</a>), I &quot;actively&quot; followed along with the show by doing things like viewing Trac to see the commit mentioned in &quot;Tracking Trunk&quot;, checking out the links to &quot;Community Catch-Up&quot; items as they spoke about them, etc.</p>
<p>Thanks for doing the show, guys!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.billdawson.com/weekly-twid-yearning-satisfied/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How one becomes lazy (when one is being translated by Django)</title>
		<link>http://www.billdawson.com/how-one-becomes-lazy-when-one-is-being-translated-by-django/</link>
		<comments>http://www.billdawson.com/how-one-becomes-lazy-when-one-is-being-translated-by-django/#comments</comments>
		<pubDate>Sat, 17 May 2008 04:07:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[i18n]]></category>

		<guid isPermaLink="false">http://www.billdawson.com/blog/?p=8</guid>
		<description><![CDATA[I&#8217;ve enjoyed digging even deeper into the lazy text questions that I came up with last time.  The &#8220;thingamajig&#8221; returned by ugettext_lazy indeed waits until unicode is called upon it, then it runs through translation.
You can see this by the way ugettext_lazy is defined.  It&#8217;s in core/utils/translation/__init__.py:

core/utils/translation/__init__.py


ugettext_lazy = lazy&#40;ugettext, unicode&#41;



That call to lazy [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve enjoyed digging even deeper into the lazy text questions that I came up with <a title="How lazy can text get?" href="http://www.billdawson.com/blog/how-lazy-can-text-get/">last time</a>.  The &#8220;thingamajig&#8221; returned by <code>ugettext_lazy</code> indeed waits until <code>unicode</code> is called upon it, then it runs through translation.</p>
<p>You can see this by the way <code>ugettext_lazy</code> is defined.  It&#8217;s in core/utils/translation/__init__.py:</p>
<div class="geshi no python">
<div class="head">core/utils/translation/__init__.py</div>
<ol>
<li class="li1">
<div class="de1">ugettext_lazy = lazy<span class="br0">&#40;</span>ugettext, <span class="kw2">unicode</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>That call to <code>lazy</code> produces a bit of functional programming magic (see core/utils/functional.py for the <code>def lazy</code>) that results in <code>ugettest_lazy</code> calling <code>ugettext</code> (the standard translation function) whenever its unicode value is requested (i.e., every time it&#8217;s used as a string.)</p>
<p>Fancy stuff, to my little brain anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.billdawson.com/how-one-becomes-lazy-when-one-is-being-translated-by-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How lazy can text get?</title>
		<link>http://www.billdawson.com/how-lazy-can-text-get/</link>
		<comments>http://www.billdawson.com/how-lazy-can-text-get/#comments</comments>
		<pubDate>Wed, 14 May 2008 23:57:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[i18n]]></category>

		<guid isPermaLink="false">http://www.billdawson.com/blog/?p=7</guid>
		<description><![CDATA[Inspired by Malcolm Tredinnick&#8217;s appearance on TWiD 19, I decided to create a small dummy site and work through the steps of translating it to German.
Setting up all the translation files was easy enough, but then the first thing that bit me was overlooking this instruction on Django&#8217;s Internationalization documentation page:
Always use lazy translations in [...]]]></description>
			<content:encoded><![CDATA[<p>Inspired by <a title="Malcolm's blog" href="http://www.pointy-stick.com/blog/">Malcolm Tredinnick</a>&#8217;s appearance on <a title="This Week in Django 19" href="http://blog.michaeltrier.com/2008/4/22/this-week-in-django-19-2008-04-20">TWiD 19</a>, I decided to create a small dummy site and work through the steps of translating it to German.</p>
<p>Setting up all the translation files was easy enough, but then the first thing that bit me was overlooking this instruction on Django&#8217;s <a title="Django Internationalization" href="http://www.djangoproject.com/documentation/i18n/">Internationalization</a> documentation page:</p>
<blockquote><p>Always use lazy translations in Django models.</p></blockquote>
<p>Such a short, innocent sentence!  Easy to miss.  But the author (Malcolm himself, I believe) means it.  <em>Always</em> use lazy translations in models.</p>
<p>My model contained:</p>
<div class="geshi no python">
<div class="head">models.py</div>
<ol>
<li class="li1">
<div class="de1"><span class="kw1">from</span> django.<span class="me1">db</span> <span class="kw1">import</span> models</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">from</span> django.<span class="me1">newforms</span> <span class="kw1">import</span> ModelForm</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">from</span> django.<span class="me1">utils</span>.<span class="me1">translation</span> <span class="kw1">import</span> ugettext as _</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">PROJECT_STATUSES = <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="st0">&#39;active&#39;</span>, _<span class="br0">&#40;</span><span class="st0">&#39;active&#39;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>, <span class="br0">&#40;</span><span class="st0">&#39;someday&#39;</span>, _<span class="br0">&#40;</span><span class="st0">&#39;someday&#39;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">class</span> Project<span class="br0">&#40;</span>models.<span class="me1">Model</span><span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; title = models.<span class="me1">CharField</span><span class="br0">&#40;</span>max_length=<span class="nu0">200</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; description = models.<span class="me1">CharField</span><span class="br0">&#40;</span>max_length=<span class="nu0">1000</span>, blank=<span class="kw2">True</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; status = models.<span class="me1">CharField</span><span class="br0">&#40;</span>max_length=<span class="nu0">10</span>, choices=PROJECT_STATUSES<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">#&#8230;..</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">class</span> ProjectForm<span class="br0">&#40;</span>ModelForm<span class="br0">&#41;</span>:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">class</span> Meta:</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; model = Project</div>
</li>
</ol>
</div>
<p>I then displayed the model form (ProjectForm) in a template.  The template also contained a language switcher, following the directions concerning the <a title="set_language" href="http://www.djangoproject.com/documentation/i18n/#the-set-language-redirect-view">set_language redirect view.</a> I ran the app and used the <code>set_language</code> redirect to set my language to German (the default language of the app was English.)  I expected the combobox &#8212; the one auto-generated by using the <code>choices</code> parameter when defining the <code>status</code> member of the model &#8212; to show me German options, because I&#8217;d defined those options (when setting the values of the <code>PROJECT_STATUSES</code> tuple) to have translated text values.</p>
<p>Of course they displayed English options instead of German, because I used <code>ugettext</code> instead of <code>ugettext_lazy</code>.  The question is, do I understand why <code>ugettext</code> doesn&#8217;t work?  One of my goals during <a title="Total Django Immersion" href="http://www.billdawson.com/blog/2008/05/15/its-time-for-total-django-immersion/">TDI</a> is to understand how and why things work the way they do in Django.  I haven&#8217;t dug into this yet, but I <em>think</em> it can be explained something like this: at the time the models.py is evaluated and, therefore, the time the <code>PROJECT_STATUSES</code> variable is filled, the thread (or whatever it&#8217;s called in this context) is still running under the site&#8217;s default locale.  Since that&#8217;s English, when <code>ugettext</code> gets called it just returns the original string, since I haven&#8217;t specified any English translations.  Only later (I guess when about to render a response?) is the user&#8217;s (i.e., session&#8217;s) locale evaluated and used.  By that time, <code>PROJECT_STATUSES</code> values have already been sent through the translation engine, so they&#8217;re not sent through again.</p>
<p>So maybe <code>ugettext_lazy</code> returns some sort of thingamajig that doesn&#8217;t call into the translation engine until its <code>__unicode__</code> function is accessed.  I would guess that&#8217;s what the documentation means by&#8230;</p>
<blockquote><p>The translation itself will be done when the string is used in a string context.</p></blockquote>
<p>I look forward to digging deeper by:</p>
<ul>
<li>Searching for and learning about the place in Django code where the switch from the default to the session-specific locale takes place.</li>
<li>Reading through the <code>ugetext_lazy</code> code to see how it works.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.billdawson.com/how-lazy-can-text-get/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>It&#8217;s time for Total Django Immersion</title>
		<link>http://www.billdawson.com/its-time-for-total-django-immersion/</link>
		<comments>http://www.billdawson.com/its-time-for-total-django-immersion/#comments</comments>
		<pubDate>Wed, 14 May 2008 23:51:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://www.billdawson.com/blog/?p=6</guid>
		<description><![CDATA[As part of my effort to better focus on Django, I hereby announce the beginning of my Total Django Immersion (TDI).  During TDI I shall&#8230;

Listen to each new TWiD as it comes out.
During the &#34;Tracking Trunk&#34; part of TWiD, choose one or two of the more interesting commits, use Django Trac to examine their [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my effort to better focus on Django, I hereby announce the beginning of my Total Django Immersion (TDI).  During TDI I shall&#8230;</p>
<ul>
<li>Listen to each new <a href="http://blog.michaeltrier.com/tags/twid" title="This Week in Django">TWiD</a> as it comes out.</li>
<li>During the &quot;Tracking Trunk&quot; part of TWiD, choose one or two of the more interesting commits, use Django Trac to examine their diffs and try to understand what&#8217;s going on.</li>
<li>Review all previous TWiD show notes.</li>
<li>Subscribe to the Django-Users mailing list.</li>
<li>When reviewing mailing list updates, pick one of the more interesting messages and dig deeply into the topic or problem discussed in that message.</li>
<li>Just generally be more ambitious about diving into Django&#8217;s source code to see how things work.</li>
</ul>
<p>Of course the time that I need to spend to do this will be taken from other parts of my day.  I&#8217;m therefore going to abandon my RSS reading lists (except feeds of Django-related content) for a month or so.  That&#8217;s one thing I think I can cut out without much suffering.  TV would be another, as would the reduction of weekend laziness.  We&#8217;ll see how it goes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.billdawson.com/its-time-for-total-django-immersion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
