Highlight?

This commit is contained in:
Tom Willemsen 2012-11-04 19:13:22 +01:00
parent 124cdee6ba
commit 7ee8c1a038

View file

@ -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