<?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>Noemi Millman &#124; Triopter &#187; django</title>
	<atom:link href="http://triopter.com/archive/category/django/feed/" rel="self" type="application/rss+xml" />
	<link>http://triopter.com</link>
	<description>Hello.  My name is Noemi Millman, and Triopter is my web development agency.  We handcraft beautiful, dynamic websites.</description>
	<lastBuildDate>Tue, 24 Apr 2012 15:27:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Django 1.0: Filtering object list and ForeignKey (ModelChoiceField) in Admin Site (contrib.admin)</title>
		<link>http://triopter.com/archive/django-10-filtering-object-list-and-foreignkey-modelchoicefield-in-admin-site-contribadmin/</link>
		<comments>http://triopter.com/archive/django-10-filtering-object-list-and-foreignkey-modelchoicefield-in-admin-site-contribadmin/#comments</comments>
		<pubDate>Fri, 15 May 2009 01:05:29 +0000</pubDate>
		<dc:creator>Noemi Millman</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://triopter.com/archive/django-10-filtering-object-list-and-foreignkey-modelchoicefield-in-admin-site-contribadmin/</guid>
		<description><![CDATA[PLEASE NOTE: The following explanation refers to Django v1.0 and is no longer fully applicable.  Since DJango 1.1 or so, the request object is passed to ModelAdmin.formfield_for_dbfield and the new ModelAdmin.formfield_for_foreignkey by default, which makes this much simpler to accomplish.
I&#8217;m currently building a custom multi-blogging application in Django, and one of the challenges I [...]]]></description>
			<content:encoded><![CDATA[<p><strong>PLEASE NOTE: The following explanation refers to Django v1.0 and is no longer fully applicable.  Since DJango 1.1 or so, the request object is passed to <code>ModelAdmin.formfield_for_dbfield</code> and the new <code>ModelAdmin.formfield_for_foreignkey</code> by default, which makes this much simpler to accomplish.</strong></p>
<p>I&#8217;m currently building a custom multi-blogging application in Django, and one of the challenges I ran into when developing the admin section was how to restrict users to seeing and editing only their own data.</p>
<p>Imagine the following (simplified) models:<br />
<code><br />
class Blog(models.Model):<br />
	&nbsp;	owner = models.OneToOneField(User, primary_key=True)<br />
	&nbsp;	title = models.CharField(max_length=32)<br />
</code><br />
<code><br />
class Entry(models.Model):<br />
	&nbsp;	blog = models.ForeignKey(Blog)<br />
	&nbsp;	slug = models.SlugField(max_length=255, db_index=True)<br />
	&nbsp;	headline = models.CharField(max_length=255)<br />
	&nbsp;	content = models.TextField()<br />
</code></p>
<p>If I want to show the user only their own entries in the admin object list, I can filter the list in the <code>ModelAdmin.queryset</code> method &#8212; simple as pie:<br />
<code><br />
class EntryAdmin(admin.ModelAdmin):<br />
	&nbsp;	def queryset(self, request):<br />
	&nbsp;		&nbsp;	qs = super(EntryAdmin,self).queryset(request)<br />
	&nbsp;		&nbsp;	return qs.filter(blog__owner=request.user)<br />
</code></p>
<p>Now, say I want to also limit what blogs the user can assign the entry to.  There&#8217;s a useful little ModelAdmin method called <code>formfield_for_dbfield</code>, but it doesn&#8217;t receive the request as an argument.  What to do?</p>
<p>Well, the <code>ModelAdmin.get_form</code> method <em>does</em> receive the request as an argument, and it gets called before <code>formfield_for_dbfield</code>.  So let&#8217;s just put the request object somewhere that we can get to it later:<br />
<code><br />
class EntryAdmin(admin.ModelAdmin):<br />
	&nbsp;	def get_form(self, request, obj=None):<br />
	&nbsp;	self.request = request<br />
	&nbsp;	f = super(EntryAdmin,self).get_form(request, obj)<br />
	&nbsp;	return f<br />
</code></p>
<p>Then when we call <code>formfield_for_dbfield</code> we have easy access to the request:</p>
<p><code><br />
class EntryAdmin(admin.ModelAdmin):<br />
	&nbsp;	def formfield_for_dbfield(self, dbfield, **kwargs):<br />
	&nbsp;		&nbsp;	if dbfield.name == 'blog':<br />
	&nbsp;		&nbsp;		&nbsp;	kwargs['queryset'] = Blog.objects.filter(owner=self.request.user)<br />
	&nbsp;		&nbsp;	return super(EntryAdmin, self).formfield_for_dbfield(dbfield, **kwargs)<br />
</code></p>
<p>Not the world&#8217;s most elegant solution, but simple and effective.  And there&#8217;s plenty more you can do with these techniques.  Gotta love Django!</p>
]]></content:encoded>
			<wfw:commentRss>http://triopter.com/archive/django-10-filtering-object-list-and-foreignkey-modelchoicefield-in-admin-site-contribadmin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Upgrading Django from Stable to Subversion</title>
		<link>http://triopter.com/archive/upgrading-django-from-stable-to-subversion/</link>
		<comments>http://triopter.com/archive/upgrading-django-from-stable-to-subversion/#comments</comments>
		<pubDate>Wed, 27 Dec 2006 05:45:52 +0000</pubDate>
		<dc:creator>Noemi Millman</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://triopter.com/archive/upgrading-django-from-stable-to-subversion/</guid>
		<description><![CDATA[Django is in fairly heavy development, heading for a 1.0 release, and not only does there seem to be a lot of new functionality in the newest versions, but some of the older functionality is expected to break.
Since word on the mailing list is that development versions are not only quite stable, but actually recommended [...]]]></description>
			<content:encoded><![CDATA[<p>Django is in fairly heavy development, heading for a 1.0 release, and not only does there seem to be a lot of new functionality in the newest versions, but some of the older functionality is expected to break.</p>
<p>Since word on the mailing list is that development versions are not only quite stable, but actually recommended over the stable version, and since I don&#8217;t have any deployed apps to worry about breaking, I thought it would be better to upgrade now than later.</p>
<p>Even better, this will make future upgrades as simple as a single subversion command (and, well, some fixes for incompatibilities, but that would be the case anyway, and probably worse if I weren&#8217;t to keep up).</p>
<p>I was a bit scared about the upgrade, but it turned out to be much much simpler than I anticipated.Â  I found a thread on the mailing list about doing <a title="Mailing list thread about upgrading Django to the subversion trunk" href="http://groups.google.com/group/django-users/browse_thread/thread/a3f43ab9894591f3/a7972b1201222e2c">just such an upgrade</a>.Â  It wasn&#8217;t very explicit, but when I extrapolated from it, it worked.<br />
Here&#8217;s what I did:</p>
<ol>
<li>located my main <code>django</code> directory (had to search for it &#8211; it was inside an egg in <code>site-packages</code>), and renamed to <code>django.bak</code> (instead of deleting&#8230; in case of emergency).
<p>If you installed using DarwinPorts, like I did, the location is probably something like:</p>
<p><code>/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django</code></li>
<li>created a directory for the new installation (anywhere your user has read, write, and execute permissions will do, it seems), and <code>cd</code>-ed into that directory</li>
<li>ran
<p><code>svn co http://code.djangoproject.com/svn/django/trunk/ django_src</code></p>
<p>and</p>
<p><code>ln -s `pwd`/django_src/django /PATH/TO/SITE-PACKAGES/django</code></p>
<p>(substituting the correct path, of course &#8212; in my case, <code>/opt/local/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages</code>)</li>
<li>Chose a good place on my <code>$PATH</code> to symlink to <code>django-admin.py</code>, and ran
<p><code>sudo ln -s ./django_src/django/bin/django-admin.py /DIR/ON/PATH/</code></p>
<p>(I dropped it in <code>/opt/local/sbin</code>, since DarwinPorts had added that to my path, and I preferred adding something there to putting it on a main system path.)</li>
</ol>
<p>And&#8230; everything&#8217;s up and running, at least in terms of the development server (I hadn&#8217;t set it up to run on Apache in the first place &#8212; I don&#8217;t know if that would complicate things).</p>
<p>Simple, huh?</p>
]]></content:encoded>
			<wfw:commentRss>http://triopter.com/archive/upgrading-django-from-stable-to-subversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adventures in Django &#8211; Comments and more</title>
		<link>http://triopter.com/archive/adventures-in-django-comments-and-more/</link>
		<comments>http://triopter.com/archive/adventures-in-django-comments-and-more/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 22:00:02 +0000</pubDate>
		<dc:creator>Noemi Millman</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://triopter.com/archive/adventures-in-django-comments-and-more/</guid>
		<description><![CDATA[I was home sick from work today, so once I felt well enough to crawl out of bed and sit in front of the computer, I decided to catch up a bit more on my Django.
Quick-n-Easy Comments
First thing I did was to replace the commenting system I&#8217;d created for my blog-app-in-progress with the commenting framework [...]]]></description>
			<content:encoded><![CDATA[<p>I was home sick from work today, so once I felt well enough to crawl out of bed and sit in front of the computer, I decided to catch up a bit more on my Django.</p>
<h2>Quick-n-Easy Comments</h2>
<p>First thing I did was to replace the commenting system I&#8217;d created for my blog-app-in-progress with the <a href="http://code.djangoproject.com/wiki/UsingFreeComment">commenting framework</a> that comes for &#8220;free&#8221; with Django.Â  It&#8217;s not as fully featured as I might like, but it&#8217;s got some pretty nifty options, and is fairly easy to set up.Â  I figured I&#8217;d rather know how to use this than re-implement comments any time I want to add them to an app.</p>
<p>There are some interesting ways to <a href="http://www.b-list.org/weblog/2006/07/16/django-tips-hacking-freecomment">extend the functionality of Django&#8217;s comment framework</a>, although I don&#8217;t really like that they require editing the original source of that framework &#8212; especially since Django itself is likely to require upgrading frequently in the near future as we approach v.1.0.Â  Hopefully either the comments framework will be expanded further, or the model inheritance branch of Django that I&#8217;ve heard rumors of will eventually make that much less of an issue.</p>
<h2>Absolute URLs</h2>
<p>One thing I discovered was that the comments framework requires that the get_absolute_url() method be defined for any class that takes comments, so I took this opportunity to replace all the paths in my app with get_absolute_url() calls.Â  Except for the paths in the date-based generic templates, since a date object doesn&#8217;t have an absolute URL method.</p>
<p>I ended up adding some more global variables to settings.py, and constructing all the URLs from those, including the ones in urls.py and in the get_absolute_url() methods.Â  This should make future changes to path structure much simpler.</p>
<h2>Templates</h2>
<p>Lastly, I wrapped everything in the blog in the base template (after troubleshooting a problem with context not passed from a custom view to a custom tag), added a template tag so I could include a date-based archive menu in the sidebar, and set up some very basic design elements in a stylesheet in the header, to visually separate the sidebars from the content (I think this will make development a bit more pleasant).</p>
<p>All in all, not bad for another 4 hours or so of work in an unfamiliar language and framework.Â  I&#8217;m very pleased with how easy it is to develop in Django, although I&#8217;m still extremely frustrated at times with documentation that fails badly to describe syntax (I&#8217;m not talking about Python syntax only, but also which optional function arguments should or shouldn&#8217;t be in a dict; or syntax for Django&#8217;s template language).</p>
<p>I&#8217;m also pleased that I&#8217;m feeling better.Â  I might even venture to add chicken soup back into my diet tonight!</p>
]]></content:encoded>
			<wfw:commentRss>http://triopter.com/archive/adventures-in-django-comments-and-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deco-What?</title>
		<link>http://triopter.com/archive/deco-what/</link>
		<comments>http://triopter.com/archive/deco-what/#comments</comments>
		<pubDate>Sun, 19 Nov 2006 20:10:40 +0000</pubDate>
		<dc:creator>Noemi Millman</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://triopter.com/archive/deco-what/</guid>
		<description><![CDATA[I&#8217;ve said before that I&#8217;m only a moderately experienced programmer.Â  One of the things I&#8217;m enjoying about learning Django is that it&#8217;s challenging me to pick up new concepts without getting bogged down in the details of implementation.
Yesterday I ran across decorators.Â  I had no idea what a decorator is, how it works, or what [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve said before that I&#8217;m only a moderately experienced programmer.Â  One of the things I&#8217;m enjoying about learning Django is that it&#8217;s challenging me to pick up new concepts without getting bogged down in the details of implementation.<br />
Yesterday I ran across decorators.Â  I had no idea what a decorator is, how it works, or what it&#8217;s used for.Â  Wikipedia <a href="http://en.wikipedia.org/wiki/Decorator_pattern">offers an overview</a>, which at least explains the general purpose, but then someone tells me that <a href="http://wiki.python.org/moin/PythonDecorators#head-caec7706f329280ac2911365840a36436f9ba5ad">Python decorators are not the same thing</a>.Â  The top Google results <a href="http://soiland.no/software/decorator">fly way over my head</a>, and finally, I land on an <a href="http://www.daniweb.com/code/snippet368.html">example that makes sense</a>.</p>
<p>So, to my understanding, a decorator is a function that gets wrapped around a second function.Â  When the second function is called, the decorator is effectively called instead, and <em>it</em> calls the second.Â  I could be completely misled, but I&#8217;m going to run with that for now.Â  If I&#8217;m wrong, won&#8217;t someone please please please correct me?</p>
]]></content:encoded>
			<wfw:commentRss>http://triopter.com/archive/deco-what/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django pretty much rocks</title>
		<link>http://triopter.com/archive/django-pretty-much-rocks/</link>
		<comments>http://triopter.com/archive/django-pretty-much-rocks/#comments</comments>
		<pubDate>Sun, 29 Oct 2006 19:28:10 +0000</pubDate>
		<dc:creator>Noemi Millman</dc:creator>
				<category><![CDATA[django]]></category>
		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://triopter.com/archive/django-pretty-much-rocks/</guid>
		<description><![CDATA[Well, I&#8217;ve built a basic blog application in Django, complete with comments (and comment moderation), categories, and date-based archives, that would actually be presentable on a public-facing website.  It took a total of about 8 hours, and I&#8217;m very impressed with the framework.
My previous praise of the documentation was a little premature.  The [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;ve built a basic blog application in Django, complete with comments (and comment moderation), categories, and date-based archives, that would actually be presentable on a public-facing website.  It took a total of about 8 hours, and I&#8217;m very impressed with the framework.</p>
<p>My previous praise of the documentation was a little premature.  The docs are a thousand times more approachable than RoR&#8217;s, and better categorized and stuff.  But they&#8217;re very lacking in descriptions of syntax, or real-world examples, and in a few cases are out of date.</p>
<p>I spent 2 hours trying to figure out how to get date-based generic views to work before realizing that the examples I was finding on Google (unfortunately there are none on the Django docs wiki) were all a year out of date, and the view had to be called completely differently.  And then it was only by chance that I finally managed to stumble across an up-to-date example of the correct way to call them.</p>
<p>Still, I feel like I sort of understand how the framework functions, which is more than I can say for RoR.  I&#8217;ll probably be sticking to this.  Once I sort out a few last questions, I&#8217;m going to need a more ambitious project to try!</p>
]]></content:encoded>
			<wfw:commentRss>http://triopter.com/archive/django-pretty-much-rocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django vs. Ruby on Rails</title>
		<link>http://triopter.com/archive/django-vs-ruby-on-rails/</link>
		<comments>http://triopter.com/archive/django-vs-ruby-on-rails/#comments</comments>
		<pubDate>Sat, 28 Oct 2006 23:57:13 +0000</pubDate>
		<dc:creator>Noemi Millman</dc:creator>
				<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://triopter.com/archive/django-vs-ruby-on-rails/</guid>
		<description><![CDATA[Well, I&#8217;ve finished the beginner tutorials for both Django and Ruby on Rails, now.
I&#8217;d actually gone a bit further with Rails, beginning an attempt at writing an app, and then pulling up short for lack of clear documentation on working with many-to-many relationships, but that was a while ago, and the docs are a bit [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;ve finished the beginner tutorials for both Django and Ruby on Rails, now.</p>
<p>I&#8217;d actually gone a bit further with Rails, beginning an attempt at writing an app, and then pulling up short for lack of clear documentation on working with many-to-many relationships, but that was a while ago, and the docs are a bit better now.</p>
<p>One thing that&#8217;s clear both from the types of tutorials they give and from the structure of the frameworks is that they were developed for different purposes.</p>
<p>Django was, as it claims, created for developing CMSes for content-heavy sites.  It&#8217;s super easy to display content, and you get an admin interface for free (not to mention permissions tables for your database), but if you want end-users to be able to interact with the site, you have to develop your own methods for updating data (although the framework does the grunt work for you, and you just have to assign variables and then object.save()).</p>
<p>RoR was meant for &#8220;Web 2.0&#8243; sites where the content is supplied by the user, and the whole purpose of the site is for the user to interact with the data.  You get an end-user interface for data manipulation for free, but setting up users, permissions, and any sort of admin interface requires developing something from scratch or choosing one of a zillion plugins.</p>
<p>I have to say that while RoR is more trendy and has a lot more momentum right now, Django seems more mature.  I like that it&#8217;s easy to understand how and why things are being accomplished, and that there appear to be generally accepted best practices in a lot of areas instead of the dozen different people&#8217;s plugins, each with pros and cons, to patch each oversight in RoR.</p>
<p>Of course, this opinion may change as I dive a bit further into Django.  If it does, I&#8217;ll let you know.</p>
]]></content:encoded>
			<wfw:commentRss>http://triopter.com/archive/django-vs-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adventures in DarwinPorts (Installing Apache2, PHP5, MySQL 4.1, PostgreSQL, and Django)</title>
		<link>http://triopter.com/archive/adventures-in-darwinports-installing-apache2-php5-mysql-41-postgresql-and-django/</link>
		<comments>http://triopter.com/archive/adventures-in-darwinports-installing-apache2-php5-mysql-41-postgresql-and-django/#comments</comments>
		<pubDate>Tue, 24 Oct 2006 02:38:58 +0000</pubDate>
		<dc:creator>Noemi Millman</dc:creator>
				<category><![CDATA[darwinports]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[os x]]></category>

		<guid isPermaLink="false">http://triopter.com/archive/adventures-in-darwinports-installing-apache2-php5-mysql-41-postgresql-and-django/</guid>
		<description><![CDATA[Yeah, that&#8217;s quite a mouthful.
I decided a couple weeks ago that I wanted to learn Django as well as Ruby on Rails.  Django is a little bit less trendy, but seems to have more flexibility, and gives you an entire admin section of your app &#8220;for free&#8221;, as opposed to RoR, for which there [...]]]></description>
			<content:encoded><![CDATA[<p>Yeah, that&#8217;s quite a mouthful.</p>
<p>I decided a couple weeks ago that I wanted to learn <a href="http://www.djangoproject.com/">Django</a> as well as <a href="http://www.rubyonrails.org/">Ruby on Rails</a>.  Django is a little bit less trendy, but seems to have more flexibility, and gives you an entire admin section of your app &#8220;for free&#8221;, as opposed to RoR, for which there are a zillion different ways to hack on user management, and no sense of &#8220;best practices&#8221; for a novice.</p>
<p>Django requires an up-to-date installation of <a href="http://www.python.org/">Python</a>, and a number of other dependencies, including a database API for Python.  The best <a href="http://www.rhonabwy.com/wp/2006/07/20/installing-django-on-macos-x-development-version/">installation instructions</a> I could find for OS X (one of the reasons I use a Mac is the availability of all these great UNIX tools that are so useful for a webmaster) recommended using <a href="http://darwinports.opendarwin.org/">DarwinPorts</a> (soon becoming <a href="http://www.macports.org/">MacPorts</a>) to simplify installation.</p>
<p>DarwinPorts is awesome.</p>
<h2>Getting the Latest Apache / PHP / MySQL</h2>
<p>I peeked through the list of available packages, and decided that as long as I was at it, I might as well add an Apache 2 / PHP 5 / MySQL 4.1 server to run on port 81 alongside the default Apache 1.3 / PHP 4 / MySQL 4.0 that I already had on port 80.</p>
<p>An earlier attempt to do this had run out of steam as I realized I would have to choose, locate, configure, and compile all my Apache modules by hand, which is really beyond my ability and ambition.  But DarwinPorts would allow me to install Apache with a whole bunch of common modules included, and would download and install all the dependencies for each one automatically.</p>
<p>Well, even on my top-of-the-line-a-year-ago machine, this stuff takes a while to compile, but about an hour later (after cursing at myself for misunderstanding the sudo -u mysql command as running MySQL and trying to fix an error by prepending a path to the username) I had a working secondary server.  DarwinPorts not only installs dependencies for each piece, and not only configures everything for you, and not only reminds you of changes to make to your $PATH variable in case the installer couldn&#8217;t, but sometimes it even tells you what commands to run after installing each program to properly do things like initalize databases.  Sweet.</p>
<p>Here&#8217;s how you do this:</p>
<ol>
<li>port install mysql4 +server</li>
<li>port install apache2 +server</li>
<li>port install php5 +mysql4 +apache2</li>
<li>copy httpd.conf.sample to httpd.conf</li>
<li>[optional] change path in DocumentRoot and associated directives</li>
<li>[optional] change Listen 80 to Listen 81 (If you want to run side-by-side with an Apache 1.3 installation on port 80)</li>
<li>add the following to the  directive:<br />
AddType application/x-httpd-php .php<br />
AddType application/x-httpd-php-source .phps</li>
</ol>
<p>Don&#8217;t forget to follow the extra directions DarwinPorts gives you.</p>
<h2>Python, PostgreSQL, and Psycopg Spell Problems</h2>
<p>I easily updated my Python installation, and then I ran into trouble.  You see, the instructions I had for DarwinPorts were for installing with SQLite.  I wanted to use PostgreSQL, partly because I figured it would be a useful thing to learn, and partly because skimming the <a href="http://www.djangoproject.com/documentation/tutorial1/">initial tutorial</a> and <a href="http://www.djangoproject.com/documentation/tutorial1/#c2268">its comments</a> had showed me that PostgreSQL was perhaps the optimal database choice because of its handling of foreign key constraints.</p>
<p>The main installation <a href="http://code.djangoproject.com/wiki/SetupOnTiger">instructions for OS X</a> used PostgreSQL, but compiled it by hand.</p>
<p>So I decided to wing it.  The DarwinPorts available ports list included three versions of the PostgreSQL package, so I picked the latest one (postgresql81), and installed it.  Then I installed the next dependency (py-egenix-mx-base).  No problem.  And then I ran into the final piece, psycopg.</p>
<p>Psycopg is a package that allows Python to interact with PostgreSQL databases.  The instructions were very specific about installing version 1.1, not version 1.0 or 2.0, of psycopg.  Great.  I asked DarwinPorts to install psycopg.</p>
<p>Well, first problem:  the DarwinPorts psycopg package depends on the postgresql8 package, not postgresql81.</p>
<p>Second problem:  every server from which it attempted to download postgresql8 timed out.</p>
<p>I was a little bit flummoxed at this point.</p>
<p>I backtracked, downloaded the source code for psycopg, compiled it by hand using the main OS X installation instructions (I had to tweak a lot of paths to reference DarwinPorts&#8217; installation locations), and boom!  I&#8217;m off and running.</p>
<p>Phew.</p>
<p>I feel like an idiot for not documenting the exact commands I used, for the edification of future generations.  If I ever do this again and am not running down blind alleys looking for solutions to problems caused by my own typos, I promise to do so faithfully.  In the meantime, here are the steps to do it the easy way (assuming the postgresql8 servers are working):</p>
<ol>
<li>sudo port install python24</li>
<li>sudo port install postgresql8</li>
<li>sudo port install py-egenix-mx-base</li>
<li>sudo port install py-psycopg</li>
<li>[optional] sudo port install subversion (If you&#8217;re using the development version of Django, or just want subversion)</li>
<li><a href="http://www.djangoproject.com/documentation/install/#install-the-django-code">Install Django</a></li>
</ol>
<p>Next up, I&#8217;ll tell you what it&#8217;s like to jump from MySQL to PostgreSQL, and all about my experiences with the Django tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://triopter.com/archive/adventures-in-darwinports-installing-apache2-php5-mysql-41-postgresql-and-django/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

