﻿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
31891	Inconsistent related field cache invalidation	Josh	nobody	"Repro:

{{{
from django.db import models


class AppUser(models.Model):
    pass


class Profile(models.Model):
    user = models.OneToOneField(
        to=AppUser,
        on_delete=models.PROTECT,
    )


a = AppUser.objects.create()
b = AppUser.objects.create()
Profile.objects.create(user=a)

b.profile # Errors, since it has not been created yet

a.profile.user_id = b.id
a.profile.save()

# Works!
Profile.objects.get(user=b)
# <Profile: Profile object (1)>

b.profile # Errors, since it uses the cached value
}}}

I can fix it by using `a.profile.user = b` which does the cache invalidation as expected. Or using `b.refresh_from_db()`
This is a contrived example but the real use-case was cloning a model instance."	Uncategorized	new	Uncategorized	3.1	Normal		orm,related,onetoone		Unreviewed	0	0	0	0	0	0
