﻿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
37499	"Error messages say ""unsaved"" when the check is whether the primary key is set"	Alin Morosanu	Alin Morosanu	"Follow-up to #36259, see ticket:36259#comment:19.

Several ORM errors call an object ""unsaved"", but the code only checks whether its primary key is set ({{{_is_pk_set()}}}). For most models these are the same. They differ when the primary key is set by hand or by a default. In comment:19, Jacob thought this wording may have led the earlier work on #36259 towards {{{_state.adding}}}.

Messages that only check the primary key:
 * {{{save() prohibited to prevent data loss due to unsaved related object '...'.}}}
 * {{{Model instances passed to related filters must be saved.}}}
 * {{{QuerySet.contains() cannot be used on unsaved objects.}}}
 * {{{get_next/get_previous cannot be used on unsaved objects.}}}
 * {{{Unsaved model instance ... cannot be used in an ORM query.}}}
 * {{{Cannot retrieve deferred field '...' from an unsaved model.}}}

Related managers already use clearer wording: {{{... instance needs to have a primary key value before this relationship can be used.}}}

Proposal: reword these to talk about the primary key, for example {{{QuerySet.contains() cannot be used on objects without a primary key.}}} Only the text changes, not the behavior. Tests that check the old text would be updated.

Is this worth doing, and should all of these change or only some?"	Cleanup/optimization	assigned	Database layer (models, ORM)	dev	Normal				Unreviewed	0	0	0	0	0	0
