[Fixed]-Django: Change the error message for validate_ipv46_address

1👍

Quick check in source reveals that you need to wrap it like this:

def my_validate_ipv46_address(value):
    try:
        validate_ipv46_address(value)
    except ValidationError:
        raise ValidationError(_('your message here'), code='invalid')

What it does is that it catches validation error raised by Django’s validator and you provide it with your own exception message. Please note, that you would ignore original message returned from validator – it may be better to still utilise it to give proper information about the cause of failure of validation.

Leave a comment