forms.URLField not default ModelForm URLField anymore
|Reported by:||amadison||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Looks like with Changeset 11456 the ModelForm URLField stopped using the forms.FormField as it's default form field. Now it just uses a regular CharField but adds the validators.URLValidator.
There are two important things that were lost when this happened.
- the ModelForm does not add on the 'http://' if it is not present, so 'www.google.com' is an invalid url when using a ModelForm, but not a regular form.
- The error message on an invalid url is now the generic 'Enter a valid value.' instead of the more helpful 'Enter a valid URL.'.
Attached is a diff for making the ModelForm URLField use the default forms.URLField again as the docs describe here
I think this will make the validator run twice, but I think that's probably ok.
Change History (7)
comment:1 Changed 6 years ago by
|Patch needs improvement:||unset|