url = models.URLField(max_length=200,
validators=[URLValidator(["http","https"])])
And then enter a value URL starting with "ftp://", the error message given
is
Enter a valid URL.
The URL is valid, so this does not give the user useful information for
fixing the problem. Something like
URL must begin with one of [http, https]
would be more helpful.
--
Ticket URL: <https://code.djangoproject.com/ticket/32954>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => wontfix
Comment:
I think using [https://docs.djangoproject.com/en/3.2/ref/models/fields
/#error-messages `error_messages`] is the way forward here.
I don't think we can change the default — too many projects will depend on
that — and I'd guess folks would object that we were leaking unwanted info
if we added extra context here.
What's a Valid URL for the application depends on the validators in play.
Lots and lots and lots of "Valid URLs" (from an RFC perspective) are
already excluded by `URLValidator.schemes`' default value. "Enter a valid
URL." already takes this into account.
I hope that makes sense.
--
Ticket URL: <https://code.djangoproject.com/ticket/32954#comment:1>