

def _populate_unsaved_relations(self, field_dict):
    for key in self._meta.rel:
        conditions = ((key in self._dirty) and (key in field_dict) and (field_dict[key] is None) and (self._obj_cache.get(key) is not None))
        if conditions:
            setattr(self, key, getattr(self, key))
            field_dict[key] = self._data[key]

dataset/ETHPy150Open coleifer/peewee/peewee.py Model._populate_unsaved_relations/original