<?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: Small but useful Django notions&#8230;</title>
	<atom:link href="http://www.elfsternberg.com/2009/09/08/small-but-useful-django-notions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.elfsternberg.com/2009/09/08/small-but-useful-django-notions/</link>
	<description>Done, and gets things smart.</description>
	<lastBuildDate>Fri, 03 Feb 2012 14:39:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Elf Sternberg</title>
		<link>http://www.elfsternberg.com/2009/09/08/small-but-useful-django-notions/comment-page-1/#comment-691</link>
		<dc:creator>Elf Sternberg</dc:creator>
		<pubDate>Wed, 09 Sep 2009 12:49:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.elfsternberg.com/?p=392#comment-691</guid>
		<description>Because then you&#039;re repeating yourself, and violating DRY.

If you create a model X with foreign keys for both your model A and model B, Django will automatically decorate instances of either model with reference managers pointing back to collections of the other model in a Many-to-many relationship through X.  Since Django sets that up at init, why do you then need to go specify either relationship in either model?

Also, look at my first point about creating circular dependencies in Django model design.  With rare exceptions, a well-designed Django project will have several silos of independent applications.  Many-to-many relationships between the applications may exist in a dependent relationship (one app &lt;i&gt;must&lt;/i&gt; know about the other) or in an independent relationship (both applications can exist separately, but a many-to-many relationship between the models of each applications gives the developer greater expressive power).  In the latter, the Many-to-many relationship should be written into a third application independent of both.  The developer knows, inside his third application, that A &quot;knows&quot; about B through X, and B &quot;knows&quot; about A through X, and the &lt;I&gt;syntax&lt;/I&gt; of A referring to B and vice versa are all there as expected, without having to clutter either A or B with excess knowledge about X.</description>
		<content:encoded><![CDATA[<p>Because then you&#8217;re repeating yourself, and violating DRY.</p>
<p>If you create a model X with foreign keys for both your model A and model B, Django will automatically decorate instances of either model with reference managers pointing back to collections of the other model in a Many-to-many relationship through X.  Since Django sets that up at init, why do you then need to go specify either relationship in either model?</p>
<p>Also, look at my first point about creating circular dependencies in Django model design.  With rare exceptions, a well-designed Django project will have several silos of independent applications.  Many-to-many relationships between the applications may exist in a dependent relationship (one app <i>must</i> know about the other) or in an independent relationship (both applications can exist separately, but a many-to-many relationship between the models of each applications gives the developer greater expressive power).  In the latter, the Many-to-many relationship should be written into a third application independent of both.  The developer knows, inside his third application, that A &#8220;knows&#8221; about B through X, and B &#8220;knows&#8221; about A through X, and the <i>syntax</i> of A referring to B and vice versa are all there as expected, without having to clutter either A or B with excess knowledge about X.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pedro Costa</title>
		<link>http://www.elfsternberg.com/2009/09/08/small-but-useful-django-notions/comment-page-1/#comment-690</link>
		<dc:creator>Pedro Costa</dc:creator>
		<pubDate>Wed, 09 Sep 2009 09:06:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.elfsternberg.com/?p=392#comment-690</guid>
		<description>Why not use ManyToMany field? Why not using the &quot;through&quot; parameter and do exactly what you say?

http://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany</description>
		<content:encoded><![CDATA[<p>Why not use ManyToMany field? Why not using the &#8220;through&#8221; parameter and do exactly what you say?</p>
<p><a href="http://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany" rel="nofollow">http://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

