def __importDiscussion(self, zip, fingerprint, replacing): comments = json.loads(zip.read('discussion.json'), object_hook=json_util.object_hook) for comment in comments: this_comment = Comment() if replacing: comment['object_pk'] = fingerprint.id del comment['id'] # Here we also have to check if user exists, otherwise we set it to anonymous try: this_user = User.objects.get(id=comment['user_id']) except: comment['user_id'] = -1 this_comment.__dict__.update(comment) this_comment.save()