﻿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
32056	Improve assigning to the reverse side of a OneToOne relationship	Yu Li	nobody	"Hello, Django 3.1 user here.

I find the fact that you cannot save by assigning to a reverse one-to-one relationship counter-intuitive.
Obviously this has confused other users, see related:

https://code.djangoproject.com/ticket/18638
https://code.djangoproject.com/ticket/18638
https://stackoverflow.com/questions/43119575/automatically-create-one-to-one-relation-when-using-reverse-field

I think when you do 

{{{
data = Data()
t = Tag.objects.create()
data.tag = t
data.save()
# refresh from db
data = Data.objects.get(pk=data.pk)
data.tag # raises DoesNotExist
}}}

You should be able to save the relation by calling `.save()` on the data object. Since ReverseOneToOneDescriptor of `.tag` has access to data fom its `__set__(self, instance, value)` method, I believe it is possible to save some information on `data` and later can be used to save the relation when calling `data.save()`.

An even worse behavior is that when creating an object using the reverse relation, the creation fails silently. For instance,
{{{
t = Tag.objects.create()
data = Data.objects.create(tag=t)
data.tag // does not exists!
}}}
 See https://stackoverflow.com/questions/43119575/automatically-create-one-to-one-relation-when-using-reverse-field

Similarly, I don't see how this can't be achieved. The fact that the code doesn't work is counter-intuitive.
At least, If this kind of behavior is unsupported by design, I believe the create method should at least throw an error.


"	New feature	closed	Database layer (models, ORM)	3.1	Normal	duplicate			Unreviewed	0	0	0	0	0	0
