#29908: Blog access in b.entry_set.all()[i].blog should not hit the database
-------------------------------------+-------------------------------------
               Reporter:  Carsten    |          Owner:  nobody
  Fuchs                              |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  1.11
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Using the example models Blog and Entry from
 https://docs.djangoproject.com/en/2.1/topics/db/queries/#related-objects,
 this code:

 {{{
 #!python
     b = Blog.objects.get(name="...")
     for e in b.entry_set.all():
         print(e.blog)   # e.blog == b
 }}}
 should not trigger an access to the database, because `e.blog == b`.
 Instead, for ''each'' `e`, the access to `e.blog` unexpectedly causes a
 query to fetch the blog object.

 (Originally posted at https://groups.google.com/d/msg/django-
 users/Jwk9yd8Mikc/DhaEf8I5BgAJ)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29908>
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.ab64c288ea87c91bbab88c4c09770089%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to