﻿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
4027	Document how to make copies of model instances	Marek Kubica	Tomek Paczkowski	"Although it does not seem documented anywhere (but I think, it should, as it is handy) model instances can be copied by setting the primary key to `None` in which case they get a new ID and get saved as new object into the database __preserving__ their old values. Unfortunately, this does not apply to `ManyToMany` fields of the model: they have to be saved before setting the primary key to `None` (`ModelInstance.manytomanyfield.all()`), then the instance has to be saved and afterwards they can be added to the new object as it has again a valid ID and saved for the second time. It seems to me that saving an object twice to circumvent this is somewhat hackish.

The most important thing to me is that copying objects should work in a clean way (setting the primary key to `None` is more or less clean enough, provided that it is documented somewhere and works as expected). Such a possibility is needed sometimes: I have to maintain a large number of objecs which often differ only in one field, so I can simply copy the old one and change the value."	New feature	closed	Documentation	dev	Normal	fixed	db, copy	pythonmailing@… simon@… Forest Bond mmitar@… tomek+django@… bruth@…	Ready for checkin	1	0	0	0	0	0
