id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 16617 URLField with min_length or max_length reports wrong length in validation messages Fraser Nevett ANUBHAV JOSHI "Here's a simple example to illustrate the problem: {{{ >>> from django.forms import URLField >>> URLField(max_length=5).clean('example.com') Traceback (most recent call last): File """", line 1, in File ""django/forms/fields.py"", line 153, in clean self.run_validators(value) File ""django/forms/fields.py"", line 142, in run_validators raise ValidationError(errors) ValidationError: [u'Ensure this value has at most 5 characters (it has 19).'] }}} The entered value (''example.com'') is only 11 characters long, but the validation message says that it is 19. This obviously has the potential to cause confusion to the user. The value 19 comes from the fact that length check is performed after the value has been sanitised to ''!http://example.com/''. A possible solution would be to add the sanitised value to the validation message so that the user can better understand to what value the length restriction actually applies. For example: Ensure this value has at most 5 characters (""!http://example.com/"" has 19). Note that the same problem occurs with `min_length` as with `max_length`." Bug closed Forms dev Normal fixed me@… Ready for checkin 1 0 0 0 0 0