#33008: Document prefetch_related for GenericForeignKey - Object doesn't exist
behaviour
--------------------------------------+------------------------------------
     Reporter:  Martin Svoboda        |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.contenttypes  |                  Version:  3.2
     Severity:  Normal                |               Resolution:
     Keywords:  Documentation         |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by Martin Svoboda):

 Thank you, you are right, assignment  {{{ tags_2[0].content_object = None
 }}} also set object_id and content_type_id is to None. However I am not
 sure if "modification" of a source object is the correct behaviour for
 prefetch_related.


 Replying to [comment:3 Simon Charette]:
 > I didn't look at the issue in detail but I assume this is happening due
 to the prefetching logic performing a `tags_2[0].content_object = None`
 assignment.
 >
 > How does the following code behaves?
 >
 > {{{#!python
 > tags_1 = TaggedItem.objects.filter(tag='test')
 > tags_1.content_object = None
 > assert tags_1.object_id is None
 > assert tags_1.content_type_id is None
 > }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33008#comment:4>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/071.827755afb4a4558b3d6bd26c2aba873e%40djangoproject.com.

Reply via email to