List Info

Thread: Newforms and GET Requests for Search Result Pagination?




Newforms and GET Requests for Search Result Pagination?
country flaguser name
United States
2007-07-30 14:31:54
Greetings,

Is it not possible to use Newforms with GET requests? I'm
trying to
figure out how to paginate results from a search form, and
I'm passing
GET values to the pagination view, instantiating an instance
of the
Form object with request.GET as an argument (instead of the
typical
request.POST). I can't find any mention of GET support in
the
documentation, is this something that will eventually be
added or has
it been decided against?

Also, does anyone know of any very clean way to paginate
search
results? I really can't believe there's no way to do this
with generic
views, it's a common thing to have to do. It's no good if
you lose
your search query every time you change pages 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Newforms and GET Requests for Search Result Pagination?
country flaguser name
United States
2007-07-30 15:00:23
> Is it not possible to use Newforms with GET requests?

It is. You can pass it any "dictionary-like"
object instance as its
submitted data (request.GET and request.POST are both
dictionary-like
objects.)

> I'm trying to
> figure out how to paginate results from a search form,
and I'm passing
> GET values to the pagination view, instantiating an
instance of the
> Form object with request.GET as an argument (instead of
the typical
> request.POST). I can't find any mention of GET support
in the
> documentation, is this something that will eventually
be added or has
> it been decided against?

It should work as you have it. Are you seeing a problem with
this?

> Also, does anyone know of any very clean way to
paginate search
> results?

Are your search results simply a query set?

Generic Views do provide pagination support. See the
"paginate_by"
argument:
http://www
.djangoproject.com/documentation/generic_views/#django-views
-generic-list-detail-object-list

If you need custom pagination in your own views see:
http://www.djangoproject.com/documentation/models/p
agination/

> I really can't believe there's no way to do this with
generic
> views, it's a common thing to have to do. It's no good
if you lose
> your search query every time you change pages 

Well, that depends. Is your search result going to
potentially return
thousands of hits? Are dozens of users going to be able to
perform
different searches at the same time?

If so, it's no good for the application to hang on to the
search
results. Consider many users launching searches and never
going to
page #2. The cached querysets will have to linger on wasting
away
precious server resources. In other words, it would be a
scalability
issue.

If your search results are limited to say a few pages or if
scalability is not a problem or if the search query is very
complex
and time-consuming to perform, you could turn your queryset
into a
list and cache it (using Django's caching framework) and
then feed it
to your view from the cache if found.





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Newforms and GET Requests for Search Result Pagination?
country flaguser name
United States
2007-07-30 15:10:28
I completely forgot to run is_valid() on the receiving view,
so
cleaned_data wasn't being populated. This was the problem.

Thanks!

On Jul 30, 4:00 pm, RajeshD <rajesh.dha...gmail.com> wrote:
> > Is it not possible to use Newforms with GET
requests?
>
> It is. You can pass it any "dictionary-like"
object instance as its
> submitted data (request.GET and request.POST are both
dictionary-like
> objects.)
>
> > I'm trying to
> > figure out how to paginate results from a search
form, and I'm passing
> > GET values to the pagination view, instantiating
an instance of the
> > Form object with request.GET as an argument
(instead of the typical
> > request.POST). I can't find any mention of GET
support in the
> > documentation, is this something that will
eventually be added or has
> > it been decided against?
>
> It should work as you have it. Are you seeing a problem
with this?
>
> > Also, does anyone know of any very clean way to
paginate search
> > results?
>
> Are your search results simply a query set?
>
> Generic Views do provide pagination support. See the
"paginate_by"
> argument:http://www.djangoproject.com/documentati
on/generic_views/#django-view...
>
> If you need custom pagination in your own views see:http://www.djangoproject.com/documentation/models/p
agination/
>
> > I really can't believe there's no way to do this
with generic
> > views, it's a common thing to have to do. It's no
good if you lose
> > your search query every time you change pages 
>
> Well, that depends. Is your search result going to
potentially return
> thousands of hits? Are dozens of users going to be able
to perform
> different searches at the same time?
>
> If so, it's no good for the application to hang on to
the search
> results. Consider many users launching searches and
never going to
> page #2. The cached querysets will have to linger on
wasting away
> precious server resources. In other words, it would be
a scalability
> issue.
>
> If your search results are limited to say a few pages
or if
> scalability is not a problem or if the search query is
very complex
> and time-consuming to perform, you could turn your
queryset into a
> list and cache it (using Django's caching framework)
and then feed it
> to your view from the cache if found.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )