models: Use copy.copy for creating copies

This commit is contained in:
Thomas Adamcik 2015-04-07 23:59:36 +02:00
parent df1636e814
commit 168c10448b

View File

@ -1,5 +1,6 @@
from __future__ import absolute_import, unicode_literals
import copy
import json
# TODO: split into base models, serialization and fields?
@ -207,8 +208,7 @@ class ImmutableObject(object):
:type values: dict
:rtype: new instance of the model being copied
"""
other = self.__class__()
other.__dict__.update(self.__dict__)
other = copy.copy(self)
for key, value in values.items():
if key not in self._fields:
raise TypeError(