<?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>David North &#187; Code</title>
	<atom:link href="http://www.dnorth.net/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dnorth.net</link>
	<description>The scribblings of an Oxford-based geek</description>
	<lastBuildDate>Sun, 29 Aug 2010 15:23:58 +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>Converting Word documents to PDF with OpenOffice and Python</title>
		<link>http://www.dnorth.net/2010/08/29/converting-word-documents-to-pdf-with-openoffice-and-python/</link>
		<comments>http://www.dnorth.net/2010/08/29/converting-word-documents-to-pdf-with-openoffice-and-python/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 15:23:58 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=265</guid>
		<description><![CDATA[The problem A word document (plain old .doc, not 2007) should be received by e-mail, fed to a script, turned into a PDF and published on a website. At my disposal My server running Debian &#8216;Lenny&#8217;, which does not have a display of any kind. How hard can it be? Harder than it should have [...]]]></description>
			<content:encoded><![CDATA[<h2>The problem</h2>
<p>A word document (plain old .doc, not 2007) should be received by e-mail, fed to a script, turned into a PDF and published on a website.</p>
<h2>At my disposal</h2>
<p>My server running Debian &#8216;Lenny&#8217;, which does not have a display of any kind.</p>
<h2>How hard can it be?</h2>
<p>Harder than it should have been, as ever. Here are my steps:</p>
<pre># aptitude install python-uno xvfb openoffice.org-java-common openoffice.org-writer unoconv
</pre>
<p>You&#8217;ll note the inclusion of <a href="http://en.wikipedia.org/wiki/Xvfb">Xvfb</a> there, because it turns out that &#8220;headless&#8221; mode in OpenOffice <a href="http://www.oooforum.org/forum/viewtopic.phtml?t=3600">isn&#8217;t really headless at all</a>. Sigh. Also sigh some more at the <a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=491456">broken dependencies of the unoconv Debian package</a>.</p>
<p>Now we can write our <a href="https://svn.dnorth.net/svn/dotfiles/trunk/pymodules/doc2pdf.py">script</a> to do the actual conversion. Shame it took twice as long as it should have&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2010/08/29/converting-word-documents-to-pdf-with-openoffice-and-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with CurrentCost</title>
		<link>http://www.dnorth.net/2010/06/22/fun-with-currentcost/</link>
		<comments>http://www.dnorth.net/2010/06/22/fun-with-currentcost/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 22:28:49 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=249</guid>
		<description><![CDATA[Five years after the cool kids first started jumping on the bandwagon, I&#8217;ve got myself a CurrentCost CC128 (Southern Electric send them to some customers for free, it seems &#8211; e.g. my granddad who didn&#8217;t want it). So, with the addition of an eight quid data cable and the Linux box running in my lounge, [...]]]></description>
			<content:encoded><![CDATA[<p>Five years after the cool kids first started jumping on the bandwagon, I&#8217;ve got myself a <a href="http://currentcost.co.uk/product-cc128.html">CurrentCost CC128</a> (<a href="http://www.southern-electric.co.uk/">Southern Electric</a> send them to some customers for free, it seems &#8211; e.g. my granddad who didn&#8217;t want it).</p>
<p>So, with the addition of an <a href="http://cgi.ebay.co.uk/Current-Cost-data-cable-USB-/180511818933?cmd=ViewItem&amp;pt=LH_DefaultDomain_3&amp;hash=item2a0757c4b5">eight quid data cable</a> and the Linux box running in my lounge, may I present <a href="http://electricity.dnorth.net">my electricity usage graphs</a>. Bear in mind that these are (at the time of writing) for a five-bedroom house in central Oxford.</p>
<p>The parser for the XML output of the device I&#8217;m using is <a href="http://code.google.com/p/currentcost/">this one</a> &#8211; just swap &#8220;COM20&#8243; for &#8220;/dev/ttyUSB0&#8243; in their testrun script and fix it to ignore empty lines read from the serial port, and you&#8217;re in business. I then hackdapted this <a href="http://www.jibble.org/currentcost/">RRDTool tutorial</a> to plot the graphs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2010/06/22/fun-with-currentcost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Are IDEs a problem?</title>
		<link>http://www.dnorth.net/2010/05/02/are-ides-a-problem/</link>
		<comments>http://www.dnorth.net/2010/05/02/are-ides-a-problem/#comments</comments>
		<pubDate>Sun, 02 May 2010 13:11:05 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Facebook]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=234</guid>
		<description><![CDATA[I&#8217;ve just read an interesting piece over at The Register on the bloated awkwardness of Visual Studio 2010, and another on the question of whether we need IDEs at all. The latter is a difficult question for me &#8211; on the one hand, there&#8217;s a school of thought I have some sympathy with, which says [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;ve just read an interesting <a href="http://www.theregister.co.uk/2010/04/26/blowing_bubbtles/">piece</a> over at <a href="http://www.theregister.co.uk">The Register</a> on the bloated awkwardness of Visual Studio 2010, and <a href="http://www.theregister.co.uk/2010/02/28/ides_versus_the_people/">another</a> on the question of whether we need IDEs at all.</p>
<p style="text-align: justify;">The latter is a difficult question for me &#8211; on the one hand, there&#8217;s a school of thought I have some sympathy with, which says that IDEs are a crutch of the feeble-minded, and allow bad programmers to kid themselves that they&#8217;re good, because they can generate lots of code automatically and hit ctrl-space if they run out of ideas.</p>
<p style="text-align: justify;">However.</p>
<p style="text-align: justify;">When I started programming, six years ago (!), the first three languages I used were Turbo Pascal for Windows, PHP and Visual Basic 6. TPW was a good basic language for teaching A-Level Computing, but the built-in editor was scarcely better than Notepad. I can&#8217;t remember if it had a compile-and-run button, but I seem to recall not. PHP was slightly better &#8211; once I&#8217;d worked out how to get Apache onto my Windows machine and sacrificed a chicken to get PHP talking to it &#8211; but again, no IDE out of the box, and even the relatively advanced capabilities built into the copy of DreamWeaver  (was I the only student in the country honest enough to cough up over £100 for it?) didn&#8217;t feel up to much.</p>
<p style="text-align: justify;">VB6, though, felt magic. In retrospect, it was a horrid language, but not only could I drop controls onto a form and double-click to generate the outline of the method they&#8217;d activate, I could actually <em>pause and resume the code while it was running</em>! I could see the values of variables at a point in execution, and even go backwards and forwards. The completion facilities of the IDE were basic, but they were there, and they made things much faster. Writing code to automate Microsoft Office was a particular sweet spot &#8211; run the macro recorder to generate code containing roughly the API calls you were after, then drop some VB6 control flow round them, and off we go.</p>
<p style="text-align: justify;">Later, reading <a href="http://www.comlab.ox.ac.uk">Computer Science at Oxford</a>, the practicals we did rarely stipulated an IDE, but we nearly always ended up using <a href="http://projects.gnome.org/gedit/">gedit</a> + the relevant command-line compiler. Certainly, the existence of <a href="http://leksah.org/">IDEs for Haskell</a> was never alluded to &#8211; either the ultimate example of clever people thinking IDEs are the preserve of the feeble-minded, or the assumption that we&#8217;d be clever enough to go and look for one ourselves, depending on how silly I want to consider myself in retrospect.</p>
<p style="text-align: justify;">I&#8217;m happy to say that Java hardly featured at all in our courses (I&#8217;m <a href="http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html">with Joel</a> on that one), but when it did, we were told to use <a href="http://www.bluej.org/">BlueJ</a>, because, <a href="http://spivey.oriel.ox.ac.uk">Mike Spivey</a> explained, &#8220;it has only two buttons, and Eclipse has hundreds of others you don&#8217;t need&#8221;.</p>
<p style="text-align: justify;">Given the short length of the practicals involved, I only paused to think &#8220;pish, how many buttons can it have?&#8221;, but I didn&#8217;t feel the need to find out for myself until I started writing Java for a living. He was right, there are hundreds of them. Despite which, I use Eclipse every day at work, and would never dream of trying to write code without it. It is, irrefutably, a big, bloated beast, but when you&#8217;re working on serious real-world Java, with version control, coding standards, complicated dependencies, hundreds of packages making up one program, and spend far more time reading and debugging code than writing it, you really do need the beast on your side (or so I believe).</p>
<p style="text-align: justify;">So that&#8217;s it, then &#8211; I&#8217;ve converted to the world of IDEs? Well, not quite. The other language I use on a day-to-day basis &#8211; though mostly for pleasure rather than business &#8211; is <a href="http://www.python.org">Python</a>. And I don&#8217;t usually use an IDE, simply bashing out code in Notepad++ on Windows, or KDevelop on Linux. OK, so KDevelop is sort-of an IDE, but it&#8217;s very lightweight.</p>
<p style="text-align: justify;">Of course, Python being interpreted rather than compiled makes it easier to just fire up your Python program from the command line after editing it. And that, really, gives us a clue as to the only sane conclusion of the IDE debate: it&#8217;s the same as the programming language debate. There are tools (languages and IDEs) and there are jobs. Good programmers pick the best tool for the job, and for a compiled language as verbose as Java, an IDE arguably makes things faster. For Python, on the other hand, it&#8217;s not essential (IMO), but it depends on the tastes of the individual.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">http://www.theregister.co.uk/2010/04/26/blowing_bubbtles/</div>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2010/05/02/are-ides-a-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SysAdmin stuff</title>
		<link>http://www.dnorth.net/2010/04/25/sysadmin-stuff/</link>
		<comments>http://www.dnorth.net/2010/04/25/sysadmin-stuff/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 17:29:40 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[SysAdmin]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=231</guid>
		<description><![CDATA[It&#8217;s amazing how many fewer afternoons I seem to spend hacking around on my servers these days. Perhaps I got a life; I certainly got a full-time job. I have however sorted a few long-standing bits and pieces out today&#8230; dnorth.net is now available over IPv6 As are its various satelite sites and www.saintcolumbas.org. Sorry, [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s amazing how many fewer afternoons I seem to spend hacking around on my servers these days. Perhaps I got a life; I certainly got a full-time job. I have however sorted a few long-standing bits and pieces out today&#8230;</p>
<h2>dnorth.net is now available over IPv6</h2>
<p>As are its various satelite sites and <a href="http://www.saintcolumbas.org.ipv4.sixxs.org/">www.saintcolumbas.org</a>. Sorry, no, there is no bouncing logo to reward those of you viewing them via such.</p>
<h2>A backup system that doesn&#8217;t Totally Suck<strong>™</strong></h2>
<p>I&#8217;ve finally retired my creaking &#8220;run a shell script to rsync them onto my laptop when I remember (i.e. every six months)&#8221; manaul backup system in favour of an encrypted LVM partition on my home server, and <a href="http://rdiff-backup.nongnu.org/">rdiff-backup</a> to make nice incremental backups of everything on a nightly basis. The instructions on how to do it are all <a href="http://www.google.com/search?q=encrypted+lvm">out</a> <a href="http://www.google.com/search?q=rdiff-backup+tutorial">there</a> on the interweb, and it&#8217;s not too difficult, fortunately. I&#8217;m a bit disappointed that <a href="https://labs.riseup.net/code/projects/show/backupninja/">backupninja</a> doesn&#8217;t support remote rdiff-backup, but I guess I should submit a patch if it bothers me that much&#8230;meanwhile, my <a href="https://svn.dnorth.net/svn/dotfiles/trunk/bin/nightly-backup.py">wrapper script</a> seems to work just fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2010/04/25/sysadmin-stuff/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>mod_wsgi delivers on the promise</title>
		<link>http://www.dnorth.net/2010/03/08/mod_wsgi-delivers-on-the-promise/</link>
		<comments>http://www.dnorth.net/2010/03/08/mod_wsgi-delivers-on-the-promise/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 22:30:22 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[SysAdmin]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=228</guid>
		<description><![CDATA[It&#8217;s been over a year since I deployed Django in production, and I wasn&#8217;t looking forward to it. Last time, I had a lot of trouble with mod_python, sessions and decimal objects refuising to pickle. Thankfully, all this really seems to have grown up in the last year &#8211; mod_wsgi is now the recommended way [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">It&#8217;s been over a year since I deployed <a href="http://www.djangoproject.com">Django</a> in production, and I wasn&#8217;t looking forward to it. Last time, I had a lot of trouble with mod_python, sessions and decimal objects refuising to pickle.</p>
<p style="text-align: justify;">Thankfully, all this really seems to have grown up in the last year &#8211; <a href="http://code.google.com/p/modwsgi/">mod_wsgi</a> is now the <a href="http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/">recommended way</a> of deploying Django in production, and following the <a href="http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango">mod_wsgi django instructions</a>, I was in business in 20 minutes. No fuss, no mess, no drama, and best of all, using daemon mode, no noticeable performance hit when serving static files and PHP off the same Apache installation. The ability to run the django project as its own unprivileged user when using daemon mode is also real handy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2010/03/08/mod_wsgi-delivers-on-the-promise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Manipulating Maildirs with Python</title>
		<link>http://www.dnorth.net/2010/01/16/manipulating-maildirs-with-python/</link>
		<comments>http://www.dnorth.net/2010/01/16/manipulating-maildirs-with-python/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:35:25 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=221</guid>
		<description><![CDATA[My e-mail still isn&#8217;t as shiny as I&#8217;d like. In particular, my use of Exim Filters to sort incoming mail into folders lacks the ability to mark messages as read (although it&#8217;s still miles ahead of the dreaded Procmail). This would be handy for high-traffic mailing lists which I don&#8217;t have time to read on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/2008/03/15/getting-serious-about-email/">My e-mail</a> still isn&#8217;t as shiny as I&#8217;d like. In particular, my use of <a href="http://exim.org/exim-html-4.50/doc/html/filter_toc.html">Exim Filters</a> to sort incoming mail into folders lacks the ability to mark messages as read (although it&#8217;s still miles ahead of the dreaded <a href="http://www.procmail.org/">Procmail</a>). This would be handy for high-traffic mailing lists which I don&#8217;t have time to read on a daily basis, but which I find it hard to ignore the &#8220;unread&#8221; icon next to the folders for.</p>
<p>One day, I should probably move to using the <a href="http://wiki.dovecot.org/LDA">Dovecot LDA</a> and its <a href="http://wiki.dovecot.org/LDA/Sieve">sieve implementation</a>, which supports the <a href="http://www.faqs.org/rfcs/rfc5232.html">&#8220;imap4flags&#8221; extension</a>, thus allowing marking messages as read, making them turn purple in Thunderbird, and all sorts of other cool stuff. Sadly, life (or this afternoon) is too short.</p>
<p>In the meantime, I&#8217;ve solved the problem in the usual way I deal with life&#8217;s imperfections: gratuitious <a href="http://python.org/">Python</a> &#8211; <a href="http://pastebin.org/77199">http://pastebin.org/77199</a> run from a crojob every five minutes.</p>
<p>(<strong>Disclaimer</strong>: letting scratty little bits of Python anywhere near something as important as your e-mail is probably a Very Bad Idea.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2010/01/16/manipulating-maildirs-with-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bogroll 0.2</title>
		<link>http://www.dnorth.net/2009/12/27/bogroll-0-2/</link>
		<comments>http://www.dnorth.net/2009/12/27/bogroll-0-2/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 18:52:17 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=217</guid>
		<description><![CDATA[Earlier this year, I hacked together a stateless RSS reader called Bogroll. It&#8217;s been doing sterling service for me at news.dnorth.net ever since. Today, I&#8217;ve sorted out a 0.2 release with the following improvements: Now caches etags/Last-Modified headers to avoid fetching a feed if it hasn&#8217;t changed since last time (thank you, Mark Pilgrim, for [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this year, I hacked together a stateless RSS reader called <a href="/2009/04/24/introducing-bogroll/">Bogroll</a>.</p>
<p>It&#8217;s been doing sterling service for me at <a href="http://news.dnorth.net">news.dnorth.net</a> ever since. Today, I&#8217;ve sorted out a 0.2 release with the following improvements:</p>
<ul>
<li>Now caches etags/Last-Modified headers to avoid fetching a feed if it hasn&#8217;t changed since last time (thank you, <a href="http://diveintomark.org">Mark Pilgrim</a>, for <a href="http://diveintopython3.org/http-web-services.html">chapter 14</a> of <a href="http://diveintopython3.org">Dive Into Python 3</a>, which reminded me to be a good citizen in this regard). I was pleased to discover that the <a href="http://feedparser.org">Universal Feed Parser</a> it&#8217;s built on top of already supports gzip and deflate compression to save bandwidth.</li>
<li>Now supports just one category per feed, because having articles appear in several categories just seems wrong to me</li>
<li>Each category now really does contain the most recent X articles from the relevant feeds, because I&#8217;ve fixed the severely broken sort-by-date logic</li>
</ul>
<p>A fair bit of refactoring has gone on under the hood, and <a href="http://svn.dnorth.net/svn/bogroll/trunk/bogroll.py">the code</a> now looks a bit more like an app and less like a ten-minute bodge. The next round will involve getting some proper unit tests in place, and possibly AJAX magic to load the articles lazily on the page.</p>
<p>You can download the <a href="http://files.dnorth.net/bogroll/releases/bogroll-0.2.zip">0.2 zip</a>, or get the <a href="http://svn.dnorth.net/svn/bogroll/trunk/">latest version from subversion</a> if you like to live dangerously. The cool kids all seem to be using Git or Mercurial these days, but I haven&#8217;t found the need (or overcome the inertia) yet.</p>
<p>Enjoy. Feedback welcome to the <a href="/contact/">usual address</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2009/12/27/bogroll-0-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenID</title>
		<link>http://www.dnorth.net/2009/05/05/openid/</link>
		<comments>http://www.dnorth.net/2009/05/05/openid/#comments</comments>
		<pubDate>Tue, 05 May 2009 20:32:45 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=129</guid>
		<description><![CDATA[You can now sign in to leave comments here (yes, dear readers, both of you!) &#8211; using an OpenID if you have one, and in related news, I&#8217;ve got m&#8217;self a shiny new OpenID to go and do likewise on other people&#8217;s sites.]]></description>
			<content:encoded><![CDATA[<p>You can now sign in to leave comments here (yes, dear readers, both of you!) &#8211; using an <a href="http://openid.net/">OpenID</a> if you have one, and in related news, I&#8217;ve got m&#8217;self a <a href="http://www.dnorth.net">shiny new OpenID</a> to go and do likewise on other people&#8217;s sites.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2009/05/05/openid/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Model inheritance in Django</title>
		<link>http://www.dnorth.net/2009/04/28/model-inheritance-in-django/</link>
		<comments>http://www.dnorth.net/2009/04/28/model-inheritance-in-django/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 12:26:18 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=122</guid>
		<description><![CDATA[a.k.a. &#8220;How to query for all objects not in a given subclass&#8221; I ran across this problem today &#8211; do please leave a comment if you know of a better way to solve it than what follows. You have two Django models, one of which inherits from the other, e.g.: class Order(models.Model): # some fields [...]]]></description>
			<content:encoded><![CDATA[<p>a.k.a. &#8220;How to query for all objects <em>not</em> in a given subclass&#8221;</p>
<p>I ran across this problem today &#8211; do please leave a comment if you know of a better way to solve it than what follows.</p>
<p>You have two Django models, one of which inherits from the other, e.g.:</p>
<pre>class Order(models.Model):
    # some fields

class DiningOrder(Order):
    # some more fields</pre>
<p>So, how do I write a query (using the Django ORM) which returns all the Orders which are not DiningOrders?</p>
<p>Apparently, this does the trick:</p>
<pre>&gt;&gt;&gt; Order.objects.all().count()
762L
&gt;&gt;&gt; DiningOrder.objects.all().count()
93L
&gt;&gt;&gt; Order.objects.exclude(id__in=[d.id for d in DiningOrder.objects.all()]).count()
669L</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2009/04/28/model-inheritance-in-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Bogroll: a stateless RSS reader</title>
		<link>http://www.dnorth.net/2009/04/24/introducing-bogroll/</link>
		<comments>http://www.dnorth.net/2009/04/24/introducing-bogroll/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 22:00:07 +0000</pubDate>
		<dc:creator>David North</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.dnorth.net/?p=118</guid>
		<description><![CDATA[My main problem with RSS readers is that if I go away for a few days and come back, I don&#8217;t really have time to catch up with all the posts which came up whilst I was away. What I needed, therefore, was a stateless reader which would just show the newest 10 entries or [...]]]></description>
			<content:encoded><![CDATA[<p>My main problem with RSS readers is that if I go away for a few days and come back, I don&#8217;t really have time to catch up with all the posts which came up whilst I was away. What I needed, therefore, was a stateless reader which would just show the newest 10 entries or so.</p>
<p>Add in category filtering and a web interface &#8211; such as it is &#8211; and you get Bogroll, which I&#8217;ve just released under the GPL. You can grab <a href="http://files.dnorth.net/bogroll/releases/bogroll-0.1.zip">the 0.1 release</a>, <a href="https://svn.dnorth.net/svn/bogroll/trunk/">check out the code from subversion</a>, and have a nosey at <a href="http://news.dnorth.net">my installation</a>.</p>
<p>Incidentally, if anyone can think of a better name for it, do get in touch.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dnorth.net/2009/04/24/introducing-bogroll/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
