Opened 15 years ago

Closed 14 years ago

Last modified 13 years ago

#13613 closed (fixed)

forms.URLField not default ModelForm URLField anymore

Reported by: amadison Owned by: nobody
Component: Forms Version: 1.2
Severity: Keywords: ModelForm URLField
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

  1. 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.
  2. 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.

Attachments (1)

db_fields.diff (695 bytes ) - added by amadison 15 years ago.

Download all attachments as: .zip

Change History (7)

by amadison, 15 years ago

Attachment: db_fields.diff added

comment:1 by anonymous, 14 years ago

Has patch: set
milestone: 1.3

it is really a bug

comment:2 by Leo Shklovskii, 14 years ago

+1 for a fix, ideally in a 1.2.x release.

We're running into this bug as well since upgrading to 1.2.

comment:3 by John-Scott Atlakson, 14 years ago

Closed #13744 as a duplicate of this ticket.

Note to self, search open tickets before debugging Django as you can be sure someone has already created a ticket with the exact same patch two months prior.

comment:4 by Russell Keith-Magee, 14 years ago

Resolution: fixed
Status: newclosed

(In [13475]) Fixed #13613 -- Ensure that forms.URLField and forms.EmailField are used on a modelform. This ensures that fields are URL and Email fields are cleaned consistently when included on model forms. Thanks to amadison for the report.

comment:5 by Russell Keith-Magee, 14 years ago

(In [13476]) [1.2.X] Fixed #13613 -- Ensure that forms.URLField and forms.EmailField are used on a modelform. This ensures that fields are URL and Email fields are cleaned consistently when included on model forms. Thanks to amadison for the report.

Backport of r13475 from trunk.

comment:6 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top