-
-
Save benbacardi/d6cd0fb8c85e1547c3c60f95f5b2d5e1 to your computer and use it in GitHub Desktop.
Great solution. For Python 3 compatibility, you might want to update it to use kwargs.items()
instead of kwargs.iteritems()
the " ? " is getting encode when I use this code. It shows like %3Fprecio=0 (precio being the variable i'm passing)
@cursologo-gh, try using the safe parameter of urlencode.
From django docs: Use safe to pass characters which don’t require encoding. For example:
q = QueryDict(mutable=True)
q['next'] = '/a&b/'
q.urlencode(safe='/')
'next=/a%26b/'
https://docs.djangoproject.com/en/2.1/ref/request-response/#django.http.QueryDict.urlencode
Great! Tanks! (line 19: for Python 3 rename iteritems() to items())
If you are working with djangos pagination and your template takes care of the page keyword, simply adding
query.pop('page', None)
before returning the query does the trick.
You're right, thanks! I'll edit it!