I'm opening a django console (to narrow the problem) and run this line:

    for sesion in 
SesionJuego.objects.filter(preguntas__respuesta__isnull=True): print 
sesion, sesion.pk

Where:

    * printing is just a sample operation. I'm getting the same error (I'll 
describe later) with any loop body.
    * SesionJuego is a custom model class, having a `preguntas` attribute 
which is the reverse side (related_name) of a ForeignKey.
    * I have this issue in an atomic view, but I can also reproduce this 
error in console.

I have 1 SesionJuego element, with 5 (related) questions in the database.

What I expect is that such loop iterates over ONE element, ONCE. What I get 
is this (see the console below):

<https://lh3.googleusercontent.com/-nDBOGdQB4cs/VAi7VVEJigI/AAAAAAAAAEA/DL9VrbmXk74/s1600/Captura%2Bde%2Bpantalla%2Bde%2B2014-09-04%2B14%3A19%3A30.png>
So if I iterate I'm getting a non-unique iteration and the second-to-fifth 
iterations will yield objects without the related `preguntas` (i.e. for 
those objects, the populated `preguntas` has a `count` of 0).

Is this a bug? Seems it is iterating over the join instead of over the 
objects. How can I work in a django-way to avoid that?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/42c4415c-2af2-4279-b005-45383e66a7f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to