def __setstate__(self, data):
        model = data.pop('model', None)
        field_name = data.pop('field_name', None)
        self.__dict__.update(data)
        if model is not None:
            self.field = model._meta.get_field(field_name)
        else:
            self.field = None
Restore the constraint
dataset/ETHPy150Open daoluan/decode-Django/Django-1.5.1/django/db/models/sql/where.py/Constraint.__setstate__