(self)
return errors
Do model validation
Do model validation
Do model validation
def _check_model_validation(self):
        """Do model validation"""
        errors = []
        for location in self.locations:
            exclude_fields = ["location_type"]  # Skip foreign key validation
            if not location.db_object.location_id:
                # Don't validate location_id if its blank because SQLLocation.save() will add it
                exclude_fields.append("location_id")
            try:
                location.db_object.full_clean(exclude=exclude_fields)
            except ValidationError as e:
                for field, issues in e.message_dict.items():
                    for issue in issues:
                        errors.append(_(
                            "Error with location in sheet '{}', at row {}. {}: {}").format(
                                location.location_type, location.index, field, issue
                        ))

        return errors
def _check_model_validation ( self ) : errors = [ ] for location in self . locations : exclude_fields = [ "location_type" ] # Skip foreign key validation if not location . db_object . location_id : # Don't validate location_id if its blank because SQLLocation.save() will add it exclude_fields . append ( "location_id" ) try : location . db_object . full_clean ( exclude = exclude_fields ) except ValidationError as e : for field , issues in e . message_dict . items ( ) : for issue in issues : errors . append ( _ ( "Error with location in sheet '{}', at row {}. {}: {}" ) . format ( location . location_type , location . index , field , issue ) ) return errors