Monday, August 3, 2015

Re: About multiple GET params persistance between requests

On Mon, Aug 03, 2015 at 11:49:09AM -0400, felix wrote:

> El 03/08/15 09:42, durirompepc@gmail.com escribió:

> >I'm in a point of my app where I've two GET params, *p* and *q*

> >(pagination and query search), and I think that the best method to

> >remember the params value when you change page is to use a string to

> >manually build up the params URL. Any ideas?

> >

> ListView might help or maybe its ancestor MultipleObjectMixin with its

> paginate_by attribute.



Or if you just want a good way to build up that query, I use QueryDict:



from django.http import QueryDict

qdict = QueryDict('', mutable=True)

qdict['p'] = my_page

qdict['q'] = my_query

my_new_url = "http://example.com/my-view?%s" % qdict.urlencode()

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20150803193041.GF12140%40fattuba.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment