def validate_python(self, values, state): ceiling = Ceiling.find_by_name(values['ceiling']['name']) if ceiling != None and ceiling != c.ceiling: message = "Duplicate Ceiling name" error_dict = {'ceiling.name': "Ceiling name already in use"} raise Invalid(message, values, state, error_dict=error_dict)