﻿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
27118	Make QuerySet.get_or_create()/update_or_create() error for a non-field in defaults	Tom Brightwell	nobody	"I'm not sure if this intended behaviour or an issue.

I came across this issue using the update_or_create method. I was passing a set of defaults where one of the keys did not match with a field on the model. When called in an update scenario the method worked and returned the updated object and False, updating the model fields which matched with the keywords provided in the defaults parameter. But in a create scenario I got a ""TypeError: '[incorrect_field_name]' is an invalid keyword argument for this function."". My test coverage was a little lacking as it only covered update scenarios, so I only came across the issue in production in a create scenario.

I presume this is because the setattr method still runs successfully against the model object, even if the keyword in defaults does not correspond to a model field?

{{{
query.py

for k, v in six.iteritems(defaults):
            setattr(obj, k, v)
}}}"	Cleanup/optimization	closed	Database layer (models, ORM)	1.9	Normal	fixed	1.11	François Freitag	Accepted	1	0	0	0	0	0
