﻿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
22048	Document ways of checking for OneToOneField	Daniele Procida	code22	"https://docs.djangoproject.com/en/dev/topics/db/examples/one_to_one/#one-to-one-relationships points out that if you try to follow the `related_name` of a OneToOneField to something that doesn't exist, you'll get a `DoesNotExist` error.

What's missing is advice on how to check if there's a related object. 

The most obvious is `hasattr`. Using the Restaurant/Place example in https://docs.djangoproject.com/en/dev/topics/db/examples/one_to_one/#one-to-one-relationships:  `hasattr(place, 'restaurant')`.

I've also seen https://djangosnippets.org/snippets/2254/ (uses `ObjectDoesNotExist`) and even things like http://stackoverflow.com/a/14743656/2422705 (uses `select_related`).

It should also be explained a little more why a missing object returns a `DoesNotExist`, rather than say `None`."	Cleanup/optimization	closed	Documentation	dev	Normal	fixed	afraid-to-commit		Accepted	1	0	0	0	1	0
