#33984: Related managers cache gets stale after saving a fetched model with new 
PK
-------------------------------------+-------------------------------------
     Reporter:  joeli                |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by joeli):

 Replying to [comment:3 Bhuvnesh]:
 > I am a bit confuse here, Using clone method all the tags are being
 copied from the old instance still the actual tags for the new instance (
 new_thing ) are empty after fetching the new instance again? why the tags
 of old instance are not cloned ?

 That is the bug here: in `.clone()` after doing `self.pk = None` and
 `self.save()` to create a new copy, `self.tags` still points to the old
 thing's related manager. So `.clone()` ends up setting the tags for the
 old instance (that already has said tags). Then it returns a thing that
 pretends to be the `new_thing` but actually returns the tags of the old
 thing unless you completely refetch it from database.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33984#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/010701831b98de32-c3a99cab-d7f5-413a-94c5-8b33e2718630-000000%40eu-central-1.amazonses.com.

Reply via email to