#20242: Django queryset 'in' operator fails on first call
----------------------------------------------+--------------------
     Reporter:  anonymous                     |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.5
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 When using the 'in' operator on a queryset, the first time the call is
 made it fails. If 'prefetch_related' is removed and 'all' is used instead
 then the problem is gone.

 {{{
 from django.db import models


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


 class Project(models.Model):
     categories = models.ManyToManyField(Category, related_name='projects')


 category_list = Category.objects.prefetch_related('projects')


 print category_list # [<Category: Category object>, <Category: Category
 object>]
 print category_list[0] in category_list # False
 print category_list[0] in category_list # True
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20242>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to