﻿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
34586	create() does not save reverse OneToOne relationship nor raise an Exception	Alan Rivas	Mariana	"When creating an object with a reverse OneToOne relationship as an argument, the method Model.create does not set the relation but does not raise an Error either.

Example:

models:

{{{
from django.db import models

class Place(models.Model):
    pass


class Restaurant(models.Model):
    place = models.OneToOneField(
        Place,
        on_delete=models.CASCADE,
        null=True,
    )
}}}

With these models if you try this:

{{{
place = Place.objects.create()
restaurant = Restaurant.objects.create()

place.restaurant = restaurant
place.save(update_fields=[""restaurant""])
}}}


You will get this error:

{{{
ValueError: The following fields do not exist in this model, are m2m fields, or are non-concrete fields: restaurant
}}}


But if you try with this code:

{{{
restaurant = Restaurant.objects.create()
place = Place.objects.create(restaurant=restaurant)
}}}

You will not get an Exception and restaurant will not be related with place either. I do understand you can't save in a reverse OneToOne relation but I think this behavior is inconsistent because of the missing Exception."	Bug	closed	Database layer (models, ORM)	4.2	Normal	fixed			Ready for checkin	1	0	0	0	0	0
