On Tue, Mar 29, 2011 at 4:40 PM, ALJ <astley.lejas...@gmail.com> wrote:

> I have a form within a view which allows users to filter results
> within a database. The request is a GET because I want the users to be
> able to bookmark the results.
>
> My querystring looks something like:
>
>
> http://127.0.0.1:8001/myapp/?organisation_name=&corporation=4&authorisation_status=
>
> My view checks the form as it comes in (form.is_valid()) and bounces
> them back if they have been messing about with the querystring. The
> validation picks up errors if I do something like
> "..&corporation=999999&...", but if I do something like
> "...&corporation=wwww&...." it brings up a traceback
>
> Exception Value:
> invalid literal for int() with base 10: 'wwww'
>
> I would have expected that the validation process would have picked up
> that it isn't valid and just returned field error.
>
>
It does, in general. This form/view:

class TestForm(forms.Form):
    num = forms.IntegerField()

def testme(request):
    if request.GET:
        tf = TestForm(request.GET)
        if tf.is_valid():
            return http.HttpResponse("Worked!")
    else:
        tf = TestForm()
    return render_to_response('form.html', {'form': tf})

rendered with a method="get" form, causes re-display of the form with an
error message "Enter a whole number." associated with the num field if the
value www is entered in the num field (or simply retrieved by a ?num=www
querystring).

How is what you are doing different from what is shown above? You have not
shown any of your code nor the full traceback, so it is hard to guess what
may be the cause of the behavior you are seeing.

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-users@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