def save(self, *args, **kwargs):
        # If not set use codename as field_name as default
        if self.field_name == '':
            self.field_name = self.codename

        # If not set use primary key attribute name as default
        if self.view_param_pk == '':
            self.view_param_pk = self.content_type.model_class()._meta.pk.get_attname()

        # First search for a method or property defined in the model class
        # Then we look in the meta field_names
        # If field_name does not exist a ValidationError is raised
        if not hasattr(self.content_type.model_class(), self.field_name):
            # Search within attributes field names
            if not (self.field_name in self.content_type.model_class()._meta.get_all_field_names()):
                raise NonexistentFieldName("Could not create rule: field_name %s of rule %s does not exist in model %s" %
                                            (self.field_name, self.codename, self.content_type.model))
        else:
            # Check if the method parameters are less than 2 including self in the count
            bound_field = getattr(self.content_type.model_class(), self.field_name)
            if callable(bound_field):
                if len(inspect.getargspec(bound_field)[0]) > 2:
                    raise RulesError("method %s from rule %s in model %s has too many parameters." %
                                        (self.field_name, self.codename, self.content_type.model))
        
        super(RulePermission, self).save(*args, **kwargs)
Validates that the field_name exists in the content_type model
dataset/ETHPy150Open maraujop/django-rules/django_rules/models.py/RulePermission.save