summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-11-04 19:13:22 +0100
committerGravatar Tom Willemsen2012-11-04 19:13:22 +0100
commit7ee8c1a03806139bffe475475927010440b57c5d (patch)
tree84fa6b0a95cf25fbacf17c26741b755b8a510554
parent124cdee6baf85d38eee9bb262c330071403df8ad (diff)
downloadsite-7ee8c1a03806139bffe475475927010440b57c5d.tar.gz
site-7ee8c1a03806139bffe475475927010440b57c5d.zip
Highlight?
-rw-r--r--posts/Silly_django_confusion.mdwn23
1 files changed, 12 insertions, 11 deletions
diff --git a/posts/Silly_django_confusion.mdwn b/posts/Silly_django_confusion.mdwn
index 39ad00b..60b87c7 100644
--- a/posts/Silly_django_confusion.mdwn
+++ b/posts/Silly_django_confusion.mdwn
@@ -8,29 +8,30 @@ page. So this is what I found:
[[!format sql """
SELECT * FROM app_table;
+ => 3 rows of data
"""]]
-<pre class="src src-sql">SELECT * FROM app_table;
- =&gt; 3 rows of data</pre>
-
-<pre class="src src-python"><span class="org-keyword">from</span> app.models <span class="org-keyword">import</span> Table
+[[!format py """
+from app.models import Table
Table.objects.count()
- =&gt; 3
+ => 3
-Table.objects.<span class="org-builtin">all</span>()
- =&gt; []</pre>
+Table.objects.all()
+ => []
+"""]]
This is weird. So I looked at the `django.db.connection.queries`
property and I realized that it was doing a join since the model
subclasses another:
-<pre class="src src-python"><span class="org-keyword">from</span> django.db <span class="org-keyword">import</span> models
+[[!format py """
+from django.db import models
-<span class="org-keyword">from</span> app.models <span class="org-keyword">import</span> SuperTable
-
-<span class="org-keyword">class</span> <span class="org-type">Table</span>(SuperTable):...</pre>
+from app.models import SuperTable
+class Table(SuperTable):...
+"""]]
Which, of course, means that in order to get the complete `Table`
instance, the related `SuperTable` instance is also required, but in