﻿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
31095	Related Manager set() should prepare values before checking for missing elements.	TZanke	Hasan Ramezani	"To update a complete list of foreignkeys, we use set() method of relatedmanager to get a performance gain and avoid remove and add keys not touched by user.

But today i noticed our database removes all foreignkeys and adds them again. After some debugging i found the issue in this condition:
https://github.com/django/django/blob/master/django/db/models/fields/related_descriptors.py#L1004

Our form returns all Foreignkeys as list of strings in cleaned_data, but the strings do not match the pk (int). After converting the strings to int, before calling set(), fixes the problem.

Question:
How to avoid this issue? Maybe all code usages of set() are using lists of strings, maybe not. I dont know at the moment.
Is is possible Django fixes this issue? Should Django fix the issue? Maybe strings should raise an exception?"	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	fixed			Accepted	1	0	0	0	1	0
