﻿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
12420	"""OneToOneField doesn't allow assignment of None"""	Kieran Brownlees	Andrii Kurinnyi	"In http://code.djangoproject.com/browser/django/trunk/django/forms/models.py (R:11874)
line 53 it states:
{{{
53 	        # OneToOneField doesn't allow assignment of None. Guard
against that
54 	        # instead of allowing it and throwing an error.
55 	        if isinstance(f, models.OneToOneField) and cleaned_data
[f.name] is None:
56 	            continue
}}}
Further reading of the function SingleRelatedObjectDescriptor which
seems to implement most of the OTOF functionality actually states:

http://code.djangoproject.com/browser/django/trunk/django/db/models/fields/related.py (R:11878)

{{{
207 	        # If null=True, we can assign null here, but otherwise
the value needs
208 	        # to be an instance of the related class.
209 	        if value is None and self.related.field.null == False:
}}}
It seems that when the code in models.py was written it was by someone who simply had null=False set, which meant that the OTOF (correctly) could not have a None value.

I found the issue when trying to set a OTOF as null in an admin form it says ""saved successfully"" but never changes the value.
"		closed	Database layer (models, ORM)	dev		fixed		Ryan Nowakowski mortas.11@… George Sakkis	Ready for checkin	1	0	0	0	0	0
