﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21584	prefetch_related child queryset does not update on create	Lucas Wiman	nobody	"When a child foreign key relationship has been prefetched, calling 
the .create method on the queryset does not update the queryset.  
I've reproduced this bug in Django 1.5.4 and Django 1.6.
 
How to reproduce:
 
models.py
{{{
#!python
from django.db import models
 
class Parent(models.Model):
    pass
 
 
class Child(models.Model):
    parent = models.ForeignKey(Parent)
}}}
 
In the shell:
 
{{{
>>> p = Parent.objects.create()
>>> list(p.child_set.all())
[]
>>> child = p.child_set.create()
>>> list(p.child_set.all())
[<Child: Child object>]
>>> 
>>> p2 = Parent.objects.create()
>>> parents = Parent.objects.filter(pk=p2.id).prefetch_related('child_set')
>>> [p2_prefetched] = parents
>>> list(p2_prefetched.child_set.all())
[]
>>> p2_prefetched.child_set.create()
<Child: Child object>
>>> list(p2_prefetched.child_set.all())
[]
}}}

The last expression should return a list with one child in it, but returns an empty list instead."	Uncategorized	closed	Database layer (models, ORM)	1.6	Normal	invalid			Unreviewed	0	0	0	0	0	0
