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?
Down is my code like
(apologise my worst english)





#views.py
def search(request):

    errors = []
    mi_form = BuscaForm(request.GET)
          if request.GET and request.GET['buscar']=='1'
###here is my search filters....

        encontrados = My_first_model.objects.filter(q)
        mi_paginator = Paginator(encontrados, 2)

                try:
                    page = int(request.GET.get('page', '1'))
                except ValueError:
                    page = 1

                try:
                    pg_encontrados = mi_paginator.page(page)
                except (EmptyPage, InvalidPage):
                    pg_encontrados =
mi_paginator.page(mi_paginator.num_pages)

 return render_to_response('search_results.html',
                {'encontrados': encontrados,
                 'pg_encontrados': pg_encontrados,}


#search_results.html

{% if pg_encontrados.object_list %}
                        {% for nodo in encontrados %}
                               {{ nodo.id }}
                        {% endfor %}
{% endif %}

{% if pg_encontrados.has_previous %}
                    <a href="?
page={{ pg_encontrados.previous_page_number }}">anterior</a>
{% endif %}

Pg {{ pg_encontrados.number }} de
{{ pg_encontrados.paginator.num_pages }}.

{% if pg_encontrados.has_next %}
                    <a href="?
page={{ pg_encontrados.next_page_number }}">siguiente</a>
{% endif %}


Thanks
Bvcelari

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