<?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>peach³ &#187; Django</title>
	<atom:link href="http://peach3.nl/blog/category/django/feed/" rel="self" type="application/rss+xml" />
	<link>http://peach3.nl/blog</link>
	<description>A web based course management system</description>
	<lastBuildDate>Mon, 31 May 2010 09:47:29 +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>Largest open-source Django project</title>
		<link>http://peach3.nl/blog/2010/03/largest-open-source-django-project/</link>
		<comments>http://peach3.nl/blog/2010/03/largest-open-source-django-project/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 18:01:32 +0000</pubDate>
		<dc:creator>Erik Scheffers</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Peach³]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[SLoC]]></category>

		<guid isPermaLink="false">http://peach3.nl/blog/?p=162</guid>
		<description><![CDATA[Thierry Schellenbach from YouTellMe.nl recently wrote on his blog that their site is probably the largest Django project in terms of codebase. Since their project isn&#8217;t open-source, it&#8217;s hard to tell if that claim is true or not.
But it got me wondering. What is the largest open-source Django-based project around?

Some times ago I already posted some &#8217;source [...]]]></description>
			<content:encoded><![CDATA[<p>Thierry Schellenbach from <a style="color: #87a019; text-decoration: none;" href="http://www.youtellme.nl/">YouTellMe.nl</a> recently <a href="http://www.mellowmorning.com/2010/03/19/django-based-startup-youtellme-nl/">wrote on his blog</a> that their site is probably the largest Django project in terms of codebase. Since their project isn&#8217;t open-source, it&#8217;s hard to tell if that claim is true or not.</p>
<p>But it got me wondering. What <em>is</em> the largest <strong>open-source</strong> Django-based project around?</p>
<p><span id="more-162"></span></p>
<p>Some times ago I already <a href="http://peach3.nl/blog/2009/11/slocs/">posted</a> some &#8217;source lines of code&#8217; (SLoCs) metrics about the Peach³ Django project (41209 at the time).</p>
<p>But is SLoCs the best way to define which project is the largest? Or maybe we should use some more &#8216;Django-based&#8217; metrics, like number of unique apps (22 for Peach³) or number of models (86)?</p>
<p>Or maybe the largest project is the project with the most people using it on a day-to-day basis (approximately 350 for Peach³ at the moment).</p>
<p>And, using any of these metrics, what would be the largest Django-based open-source project around at the moment? I could not find any metrics of any other projects.</p>
<p>I feel Peach³ might actually be one of the bigger projects out there, but I have nothing to base that feeling on.</p>
]]></content:encoded>
			<wfw:commentRss>http://peach3.nl/blog/2010/03/largest-open-source-django-project/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Migrating Django models with south and converting data</title>
		<link>http://peach3.nl/blog/2009/02/migrating-django-models-with-south-and-converting-data/</link>
		<comments>http://peach3.nl/blog/2009/02/migrating-django-models-with-south-and-converting-data/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 10:08:05 +0000</pubDate>
		<dc:creator>Erik Scheffers</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[south]]></category>

		<guid isPermaLink="false">http://peach3.nl/blog/?p=125</guid>
		<description><![CDATA[I use South whenever a model needs to be changed. One thing that is not really documented in the South documentation is how to convert data. After some trial and error I found a way to use Django QuerySets to access both the old and new models to convert data.
 For example, I used to [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://south.aeracode.org/" target="_blank">South</a> whenever a model needs to be changed. One thing that is not really documented in the South documentation is how to convert data. After some trial and error I found a way to use Django QuerySets to access both the old and new models to convert data.</p>
<p><span id="more-125"></span> For example, I used to have two models defined like this:</p>
<pre lang="python">class Assignment(models.Model):
    course = models.ForeignKey(Course)
    name = models.CharField(max_length=100)

class AssignmentEdition(models.Model):
    assignment = models.ForeignKey(Assignment)
    # ... other fields</pre>
<p>The way the assignments were defined, each edition of an assignment has the same name. I needed to change this into:</p>
<pre lang="python">class Assignment(models.Model):
    course = models.ForeignKey(Course)

class AssignmentEdition(models.Model):
    assignment = models.ForeignKey(Assignment)
    name = models.CharField(max_length=100)
    # ... other fields</pre>
<p>Each edition has it&#8217;s own name. It&#8217;s still possible for editions to have the same name, but it is also possible to have a different name and still be an edition of the same assignment.</p>
<p>During the migration I want each assignment edition to get the name of it&#8217;s assignment. One way to do this is to use SQL queries to get the names of the assignments and update the assignment edition names, but that&#8217;s not very Django-like. I want to use QuerySets. I solved it in the following way (this works with Django 1.0.2 and South 0.4):</p>
<pre lang="python">from south.db import db
from django.db import models

class Assignment(models.Model):
    name = models.CharField(max_length=100)

    class Meta:
        db_table = 'assignment_assignment'
        app_label = 'assignment_migrations_0002_assignment_names'

class AssignmentEdition(models.Model):
    assignment = models.ForeignKey(Assignment)
    name = models.CharField(max_length=100)

    class Meta:
        db_table = 'assignment_assignmentedition'
        app_label = 'assignment_migrations_0002_assignment_names'

class Migration:
    def forwards(self):
        db.start_transaction()

        # Add the new name column to AssignmentEdition
        db.add_column('assignment_assignmentedition', 'name',
                      models.CharField(max_length=100))

        # Convert the existing data
        if not db.dry_run:
            db.commit_transaction()
            db.start_transaction()

            for ae in AssignmentEdition.objects.all():
                ae.name = ae.assignment.name
                ae.save()

        # Delete the name column from Assignment
        db.delete_column('assignment_assignment', 'name')

        db.commit_transaction()

    def backwards(self):
        raise NotImplementedError</pre>
<p>First, I need to create the models as they are when I want to convert the data. I can&#8217;t rely on definitions in <code>models.py</code> because first of all Assignment won&#8217;t have any name defined there, and secondly a future migration might remove the name field from AssignmentEdition as well. Also I only include the fields that are needed for the conversion here, so eg. the course field in Assignment is not included.</p>
<p>The Meta options are required for Django to be able to find the correct database tables. The <code>db_table</code> meta option is the table name (as created by Django), the <code>app_label</code> meta option is required because Django caches it&#8217;s models, and if I were to define another AssignmentEdition in another migration, Django will use the AssignmentEdition defined here instead of the one for that migration. It uses <code>app_label</code> as the key for this caching, so <code>app_label</code> needs to be a unique label for this migration.</p>
<p>The rest is pretty straightforward: after adding the new <code>name</code> column and saving the transaction, I can loop over all existing assignment editions and update the name field using a standard Django QuerySet. After the conversion the name column in Assignment can be deleted.</p>
]]></content:encoded>
			<wfw:commentRss>http://peach3.nl/blog/2009/02/migrating-django-models-with-south-and-converting-data/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My Django development environment</title>
		<link>http://peach3.nl/blog/2009/02/my-django-development-environment/</link>
		<comments>http://peach3.nl/blog/2009/02/my-django-development-environment/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 14:10:39 +0000</pubDate>
		<dc:creator>Erik Scheffers</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[aptana]]></category>
		<category><![CDATA[buildout]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://peach3.nl/blog/?p=78</guid>
		<description><![CDATA[IDE
After using a few other IDE&#8217;s I settled down with Eclipse with Aptana plug-in as the IDE I use for peach³ development. This one environment has support for everything I need while developing a Django application: Python, HTML and JavaScript support is great, with code completion, including completion for the Ext.js javascript library. And I [...]]]></description>
			<content:encoded><![CDATA[<h3>IDE</h3>
<p>After using a <a href="http://pype.sourceforge.net/" target="_blank">few</a> <a href="http://pythonide.blogspot.com/" target="_blank">other</a> <a href="http://www.kdevelop.org/" target="_blank">IDE</a>&#8217;s I settled down with <a href="http://www.eclipse.org/" target="_blank">Eclipse</a> with <a href="http://www.aptana.com/" target="_blank">Aptana</a> plug-in as the IDE I use for peach³ development. This one environment has support for everything I need while developing a Django application: Python, HTML and JavaScript support is great, with code completion, including completion for the Ext.js javascript library. And I even have the idea that I&#8217;m not using the full power of Eclipse yet.</p>
<p><span id="more-78"></span></p>
<p>By default, Eclipse and Aptana have no Python support, but it can be integrated with <a href="http://fabioz.com/pydev/manual_101_root.html">PyDev</a>.</p>
<p>The only thing missing to make it <em>the</em> best environment (in my opinion) is support for Django template tags: a Django template tag inside a HTML or JavaScript file usually results in an inline error message. But you can just ignore these error messages.</p>
<p>For some of the most used Django management commands (runserver and test) I&#8217;ve defined &#8216;tools&#8217; in the Eclipse interface and I can now start my development server or run the testsuite with a single click inside Eclipse.</p>
<p>Here is how I set up the single-click runserver tool:</p>
<p>In &#8220;<em>Run</em> &gt; <em>External Tools</em> &gt; <em>External Tools&#8230;</em>&#8221; I&#8217;ve added a new tool called &#8220;Django Runserver&#8221; and I set up the following on the <em>Main</em>-tab of the tool configuration:</p>
<table border="0">
<tbody>
<tr>
<td><strong>Location:</strong></td>
<td><code>${workspace_loc:/django/bin/django}</code></td>
</tr>
<tr>
<td><strong>Working Directory:</strong></td>
<td><code>${workspace_loc:/django}</code></td>
</tr>
<tr>
<td><strong>Arguments:</strong></td>
<td><code>runserver localhost:8080</code></td>
</tr>
</tbody>
</table>
<p>I had to setup one more thing: without it, some of the output is lost and output on standard out and standard error won&#8217;t be in the correct order: On the <em>Environment</em>-tab of the tool configuration I had to add the environment variable &#8216;<code>PYTHONUNBUFFERED</code>&#8216; with value &#8216;Y&#8217;.</p>
<p>That&#8217;s it. Now you can click &#8216;Django runserver&#8217; in the tools menu (see picture below) and the Django development server starts, with it&#8217;s output captured inside Eclipse.</p>
<p><img class="aligncenter size-full wp-image-95" title="eclipse-tools" src="http://peach3.nl/blog/wp-content/uploads/2009/02/eclipse-tools.png" alt="eclipse-tools" width="500" height="298" /></p>
<p>I&#8217;ve set up a similar tool to run the tests and to update the development environment, for which I use buildout.</p>
<h3>zc.buildout</h3>
<p>Using tips <a href="http://www.stereoplex.com/two-voices/a-django-development-environment-with-zc-buildout" target="_blank">in this blog posting</a> I have set up a development environment that is seperate from my local python installation using zc.buildout. This has the advantage that I do not have to keep track of the versions of all the python packages and external Django apps I&#8217;m using, all this information is stored in the buildout configuration. A simple &#8220;<code>bin/buildout</code>&#8221; command suffices to setup a working environment for a local development version of peach³, and I&#8217;ve set this command up as another tool in Eclipse.</p>
<p>Here is snippet of my current <strong>buildout.cfg</strong>:</p>
<pre lang="text">[buildout]
parts =
  django
  extras
eggs =
  werkzeug
  pytz
  pygments
  chardet
  docutils
  south
  python-memcached
  mysql-python

[extras]
recipe = iw.recipe.subversion
urls =
  http://django-command-extensions.googlecode.com/svn/trunk/ django-command-extensions

[django]
recipe = djangorecipe
version = 1.0.2
settings = development
project = peach3
eggs =
  ${buildout:eggs}
extra-paths =
  ${extras:location}/django-command-extensions/</pre>
<p>This script contains everything needed to setup the right environment for the Django development server.</p>
]]></content:encoded>
			<wfw:commentRss>http://peach3.nl/blog/2009/02/my-django-development-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
