The most secure way to retrieve a parameter is to use the get method
of the QueryDict.

So, instead of:
request.GET['buscar']
do:
request.GET.get('buscar', 'default_value')

Or check if the key exists in the QueryDict instance before trying to
retrieve it, with:
if 'buscar' in request.GET:
   buscar = request.GET['buscar']

;-)

-- Rodrigo Chacon


On Nov 25, 12:42 pm, Nick Arnett <nick.arn...@gmail.com> wrote:
> On Thu, Nov 25, 2010 at 6:35 AM, bvcelari <bvcel...@gmail.com> wrote:
> > Hy,
> > I'm trying to deploy my first django app, and I'm trying to use
> > pagination , I 'm using Django 1.2
> > I'm using a simple view with form, and with the request show the
> > results paginated. when I try to go to next page
> > the message appears:
> > "Key 'buscar' not found in <QueryDict: {u'page': [u'2']}>"
> > buscar is a hidden value used for check if the request comes from the
> > search form.
> > I think this message comes from the "request" URL is not properly
> > generated in fact my link targets to
> > "http://localhost:8000/search/?page=2";
> > instead of something like this:
> > "http://localhost:8000/search/?option_value1=7&option_value2=3&page=2";
> > There is any way to maintain the searchred url and indicate wich is
> > the next page?
>
> You need to pass that variable to the template, then add it to the page it
> as a hidden input.
>
> For example:
>
> <input type="hidden" name="buscar" value="{{ buscar }}"></input>
>
> Nick

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