<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Office Resource Locator Ported to Django</title>
	<atom:link href="http://www.heikkitoivonen.net/blog/2009/05/26/office-resource-locator-ported-to-django/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.heikkitoivonen.net/blog/2009/05/26/office-resource-locator-ported-to-django/</link>
	<description>A Finn in Silicon Valley - Adventures in Technology</description>
	<lastBuildDate>Wed, 17 Aug 2011 08:58:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: Heikki Toivonen</title>
		<link>http://www.heikkitoivonen.net/blog/2009/05/26/office-resource-locator-ported-to-django/comment-page-1/#comment-11511</link>
		<dc:creator>Heikki Toivonen</dc:creator>
		<pubDate>Wed, 27 May 2009 16:27:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=833#comment-11511</guid>
		<description>@James: I was assuming that I&#039;d need to be inside the &quot;mysite&quot; directory to be able create apps with the manage script, which then makes imports of the form mysite.myapp. I know I can manually move myapp elsewhere and modify PYTHONPATH and the imports, but this feels like running through unnecessary hoops. But on second look, it seems like manage.py startapp takes two options (settings, pythonpath) that maybe let you do it without those manual steps.

Thanks for the link to the queryset document; for some reason I had missed the existence of the whole document! No wonder I felt limited without seeing this.

I know there is a school of thought that thinks templates should not allow any code to run because, well, they are templates. But in practice this seems to lead to hacks to work around this limitation (like the arithmetic example above). This reminds me of the Python &quot;private&quot; members: you indicate you think something is an implementation detail by starting the name with an underscore, but there is nothing stopping others from using it if they have to. I feel like templates should be the same: you should avoid putting code there, but when it makes sense to put some code in a template then please let me.

@masklinn: Ah, I think you hit the nail on the head on that MEDIA_URL. Thank you! As for PYTHONPATH, I grant this is probably just a personal preference, but whenever my script or application needs to touch PYTHONPATH it feels like a hack. I prefer putting my things in site-packages, and deploying things in virtualenvs (which, ironically, modifies PYTHONPATH but I don&#039;t mind since it is not in my script). But it seems virtualenv has a way to create bootstrap scripts so maybe this could lead to a nice way to deploy a Django app.</description>
		<content:encoded><![CDATA[<p>@James: I was assuming that I&#8217;d need to be inside the &#8220;mysite&#8221; directory to be able create apps with the manage script, which then makes imports of the form mysite.myapp. I know I can manually move myapp elsewhere and modify PYTHONPATH and the imports, but this feels like running through unnecessary hoops. But on second look, it seems like manage.py startapp takes two options (settings, pythonpath) that maybe let you do it without those manual steps.</p>
<p>Thanks for the link to the queryset document; for some reason I had missed the existence of the whole document! No wonder I felt limited without seeing this.</p>
<p>I know there is a school of thought that thinks templates should not allow any code to run because, well, they are templates. But in practice this seems to lead to hacks to work around this limitation (like the arithmetic example above). This reminds me of the Python &#8220;private&#8221; members: you indicate you think something is an implementation detail by starting the name with an underscore, but there is nothing stopping others from using it if they have to. I feel like templates should be the same: you should avoid putting code there, but when it makes sense to put some code in a template then please let me.</p>
<p>@masklinn: Ah, I think you hit the nail on the head on that MEDIA_URL. Thank you! As for PYTHONPATH, I grant this is probably just a personal preference, but whenever my script or application needs to touch PYTHONPATH it feels like a hack. I prefer putting my things in site-packages, and deploying things in virtualenvs (which, ironically, modifies PYTHONPATH but I don&#8217;t mind since it is not in my script). But it seems virtualenv has a way to create bootstrap scripts so maybe this could lead to a nice way to deploy a Django app.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: masklinn</title>
		<link>http://www.heikkitoivonen.net/blog/2009/05/26/office-resource-locator-ported-to-django/comment-page-1/#comment-11494</link>
		<dc:creator>masklinn</dc:creator>
		<pubDate>Wed, 27 May 2009 09:19:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=833#comment-11494</guid>
		<description>Re media paths, using RequestContext will inject your settings.MEDIA_URL value in your templates (as {{ MEDIA_URL }}).

For PYTHONPATH, how&#039;s setting it so that you can &quot;see&quot; your urls a hack? (alternatively, you can use virtualenv, put the app you&#039;re working on in your virtualenv directory and launch your servers &amp; al from there)</description>
		<content:encoded><![CDATA[<p>Re media paths, using RequestContext will inject your settings.MEDIA_URL value in your templates (as {{ MEDIA_URL }}).</p>
<p>For PYTHONPATH, how&#8217;s setting it so that you can &#8220;see&#8221; your urls a hack? (alternatively, you can use virtualenv, put the app you&#8217;re working on in your virtualenv directory and launch your servers &amp; al from there)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Bennett</title>
		<link>http://www.heikkitoivonen.net/blog/2009/05/26/office-resource-locator-ported-to-django/comment-page-1/#comment-11487</link>
		<dc:creator>James Bennett</dc:creator>
		<pubDate>Wed, 27 May 2009 06:55:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=833#comment-11487</guid>
		<description>Oh, and missed one point about the template language: in general, it&#039;s meant to be much more restrictive than other templating engines. What I&#039;ve personally found is that if I&#039;m writing a complicated piece of template code to work around a perceived limitation in the language, it&#039;s often because I&#039;m really trying to move application logic out into my templates, and I almost always end up refactoring to produce a much cleaner solution. YMMV, of course, which is why we don&#039;t force you to use Django&#039;s template system :)</description>
		<content:encoded><![CDATA[<p>Oh, and missed one point about the template language: in general, it&#8217;s meant to be much more restrictive than other templating engines. What I&#8217;ve personally found is that if I&#8217;m writing a complicated piece of template code to work around a perceived limitation in the language, it&#8217;s often because I&#8217;m really trying to move application logic out into my templates, and I almost always end up refactoring to produce a much cleaner solution. YMMV, of course, which is why we don&#8217;t force you to use Django&#8217;s template system <img src='http://www.heikkitoivonen.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Bennett</title>
		<link>http://www.heikkitoivonen.net/blog/2009/05/26/office-resource-locator-ported-to-django/comment-page-1/#comment-11486</link>
		<dc:creator>James Bennett</dc:creator>
		<pubDate>Wed, 27 May 2009 06:53:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.heikkitoivonen.net/blog/?p=833#comment-11486</guid>
		<description>I&#039;m a bit confused as to your trouble with &quot;imports&quot; -- Django applications are simply Python modules, live on the import path like anything else and should be importable like anything else. You *can* stick them elsewhere and do path hacking, but I don&#039;t really know of anyone who recommends that (and though the tutorial stuffs an application inside a project directory in order to stay focused on Django and avoid the need to teach people Python basics like the import path, I&#039;ve been campaigning for a while to change that).

Media and templates are harder. The short answer is that I personally don&#039;t think there&#039;s such a thing as truly portable templates and media for public-facing parts of an application; backend logic is easy, but providing something which A) is good enough for cases where you can make it fit and B) easy enough to override in the majority of cases where you can&#039;t is, well, impossible :)

The long answer is that you can probably solve this by giving up on Python and instead doing everything through setuptools APIs, but I&#039;m not a big fan of that.

Also, you might want to look again at the database API documentation; what you found was simply a shortcut for declaring default ordering for queries on a particular model. The full API documentation lists the &quot;order_by()&quot; method of querysets, which is what you want for per-query ordering:

http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields</description>
		<content:encoded><![CDATA[<p>I&#8217;m a bit confused as to your trouble with &#8220;imports&#8221; &#8212; Django applications are simply Python modules, live on the import path like anything else and should be importable like anything else. You *can* stick them elsewhere and do path hacking, but I don&#8217;t really know of anyone who recommends that (and though the tutorial stuffs an application inside a project directory in order to stay focused on Django and avoid the need to teach people Python basics like the import path, I&#8217;ve been campaigning for a while to change that).</p>
<p>Media and templates are harder. The short answer is that I personally don&#8217;t think there&#8217;s such a thing as truly portable templates and media for public-facing parts of an application; backend logic is easy, but providing something which A) is good enough for cases where you can make it fit and B) easy enough to override in the majority of cases where you can&#8217;t is, well, impossible <img src='http://www.heikkitoivonen.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The long answer is that you can probably solve this by giving up on Python and instead doing everything through setuptools APIs, but I&#8217;m not a big fan of that.</p>
<p>Also, you might want to look again at the database API documentation; what you found was simply a shortcut for declaring default ordering for queries on a particular model. The full API documentation lists the &#8220;order_by()&#8221; method of querysets, which is what you want for per-query ordering:</p>
<p><a href="http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields" rel="nofollow">http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

