Re: Validation problem with newforms and initial value for URLField

2007-08-26 Thread Shev

Yes, I've created a custom clean method to deal with this for now,
thanks.

Perhaps the docs should be updated to have a note on that example.  On
my page, I wanted to include an initial "http://"; value so users would
not be confused as to what was expected in the field, but the field
was also optional.



On Aug 26, 3:23 am, "Peter Melvyn" <[EMAIL PROTECTED]> wrote:
> On 8/26/07, Shev <[EMAIL PROTECTED]> wrote:
>
> > But neither should an initial field value raise an error when
> > the POSTed data is exactly the same as the starting value;
> > it should just be ignored and the value discarded.
>
> Even if you supply a valid inital value? It does not sound well for me...
>
> If you need such behaveour, should not you sublass a field and
> override the clean() method?
>
> Peter


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



Re: Validation problem with newforms and initial value for URLField

2007-08-26 Thread Peter Melvyn

On 8/26/07, Shev <[EMAIL PROTECTED]> wrote:

> But neither should an initial field value raise an error when
> the POSTed data is exactly the same as the starting value;
> it should just be ignored and the value discarded.

Even if you supply a valid inital value? It does not sound well for me...

If you need such behaveour, should not you sublass a field and
override the clean() method?


Peter

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



Re: Validation problem with newforms and initial value for URLField

2007-08-25 Thread Shev

No, invalid data should not pass.  But neither should an initial field
value raise an error when the POSTed data is exactly the same as the
starting value; it should just be ignored and the value discarded.


On Aug 25, 7:32 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 8/25/07, Shev <[EMAIL PROTECTED]> wrote:
> ...
>
> > However, what I'm seeing is that when I actually do set
> > initial='http://' for a URLField, either in the field definition above
> > or via passing in a dictionary for dynamic initial values, if I then
> > submit/POST the form without changing the URLField, it gives an error
> > that the URL is invalid (of course 'http://' by itself is not a valid
> > URL).  Shouldn't the validation step know to ignore a form field value
> > if it's the same as the initial= value??
>
> You'd prefer invalid data would pass validation?
>
> If you provide an invalid initial value, I'd expect it not to pass.  No?


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



Re: Validation problem with newforms and initial value for URLField

2007-08-25 Thread Jeremy Dunck

On 8/25/07, Shev <[EMAIL PROTECTED]> wrote:
...
> However, what I'm seeing is that when I actually do set
> initial='http://' for a URLField, either in the field definition above
> or via passing in a dictionary for dynamic initial values, if I then
> submit/POST the form without changing the URLField, it gives an error
> that the URL is invalid (of course 'http://' by itself is not a valid
> URL).  Shouldn't the validation step know to ignore a form field value
> if it's the same as the initial= value??

You'd prefer invalid data would pass validation?

If you provide an invalid initial value, I'd expect it not to pass.  No?

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



Validation problem with newforms and initial value for URLField

2007-08-25 Thread Shev

So in the docs, it says one can set an initial value for form fields
via the initial attribute, e.g. from the docs:

class CommentForm(forms.Form):
... name = forms.CharField(initial='Your name')
... url = forms.URLField(initial='http://')
... comment = forms.CharField()
f = CommentForm(auto_id=False)

The docs also state that the initial values will not be used as
fallback values during a form validation.

However, what I'm seeing is that when I actually do set
initial='http://' for a URLField, either in the field definition above
or via passing in a dictionary for dynamic initial values, if I then
submit/POST the form without changing the URLField, it gives an error
that the URL is invalid (of course 'http://' by itself is not a valid
URL).  Shouldn't the validation step know to ignore a form field value
if it's the same as the initial= value??


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



Validation problem with newforms and initial value for URLField

2007-08-25 Thread Shev

So in the docs, it says one can set an initial value for form fields
via the initial attribute, e.g. from the docs:

class CommentForm(forms.Form):
... name = forms.CharField(initial='Your name')
... url = forms.URLField(initial='http://')
... comment = forms.CharField()
f = CommentForm(auto_id=False)

The docs also state that the initial values will not be used as
fallback values during a form validation.

However, what I'm seeing is that when I actually do set
initial='http://' for a URLField, either in the field definition above
or via passing in a dictionary for dynamic initial values, if I then
submit/POST the form without changing the URLField, it gives an error
that the URL is invalid (of course 'http://' by itself is not a valid
URL).  Shouldn't the validation step know to ignore a form field value
if it's the same as the initial= value??


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