Opened 6 years ago

Closed 6 years ago

#13447 closed (worksforme)

URLField fails validation for a valid URL

Reported by: emson Owned by: nobody
Component: Forms Version: 1.1
Severity: Keywords: fields, urlfield, regex
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The URLField seems to fails validation when it tries to match the following URL:

This is an affiliate link that was automatically generated. The problem seems to be occurring when the regular expression matches the second domain i.e.
Basically the regex thinks that the second domain shouldn't have a '%' after it so fails.

Can you confirm that this is correct with you?


Change History (1)

comment:1 Changed 6 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

Works for me.

>>> class MyForm(forms.Form):
...     url = forms.URLField()

>>> data = {'url': ''}
>>> f = MyForm(data=data)
>>> print f.is_valid()
>>> print f.cleaned_data['url']
Note: See TracTickets for help on using tickets.
Back to Top