def __init__(self, char_id): self.char_id = char_id try: self.p = MongoPrison.objects.get(id=self.char_id) except DoesNotExist: self.p = MongoPrison(id=self.char_id) self.p.save()