On Wed, Jun 16, 2010 at 1:29 PM, aurel...@gmail.com <aurel...@gmail.com>wrote:

> Hi,
>
> I have a model with URLField. Parmether verify_exists is set to True,
> but when I enter url that does not exists (e.g. http://foobarbarfoo.com,
> or http://www.google.com/foobar) they somehow manage to get to the
> DB.
>
> Should model report error? Or I do not understand docs: "If True (the
> default), the URL given will be checked for existence (i.e., the URL
> actually loads and doesn't give a 404 response)." on
> http://docs.djangoproject.com/en/dev/ref/models/fields/#urlfield
>
>
This checking is done either when a ModelForm based on the model is used, or
when full_clean() on a model instance is called. In the code you show you do
neither of these things. You have created a regular Form with URLField, but
when you create this form field you do not specify verify_exists=True. So
when is_valid() is called on that form, it returns True even when the
specified URL does not exist, because cleaning the form URL field does not
check for the existence of the URL, since the form does not ask for that.
Then the data from the cleaned form is used to create a model instance, but
full_clean() is not called before saving that instance, so again the
validation is bypassed. Easiest fix is to specify verify_exists on your
form's URLField.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to