﻿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
9029	`get_or_create` broken due to inconsistent behaviour between `create` and `filter` on Manager, RelatedManager, QuerySet, etc.	Tai Lee	aaron	"When calling `create`, the value for a `ForeignKey` field must be an instance of the appropriate model, e.g. `Model.objects.create(relatedfield=obj)`. To use a primary key as the value instead of a model instance, you must use the database field name as the keyword, e.g. `Model.objects.create(relatedfield_id=N)`.

When calling `filter` (or `get`), you cannot use the database field name as the keyword, but you can use either a model instance or a primary key as the value, e.g. `Model.objects.filter(relatedfield_id=N` does not work, but `Model.objects.filter(relatedfield=obj)` and `Model.objects.filter(relatedfield=N)` both work.

This makes it impossible to use primary keys as values for `ForeignKey` fields with `get_or_create`, e.g. `Model.objects.get_or_create(relatedfield_id=N, defaults={'otherfield': otherfield})` raises a `FieldError` exception.

"		closed	Database layer (models, ORM)	dev		fixed	get_or_create get create filter FieldError		Ready for checkin	1	0	0	0	0	0
