Last active
August 25, 2024 23:07
-
-
Save benbacardi/d6cd0fb8c85e1547c3c60f95f5b2d5e1 to your computer and use it in GitHub Desktop.
Django query_transform templatetag
@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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the " ? " is getting encode when I use this code. It shows like %3Fprecio=0 (precio being the variable i'm passing)