David542 David542 - 2 months ago 10
Python Question

How to retrieve a GET variable with a hash in it

I have the following variable that is passed in a url:


I need to be able to extract the following:

Platform = Comcast
PlatformID = 7066191365225244112#S8

However, django will escape the hash in the request.GET dictionary. Here is what it shows:

GET:<QueryDict: {u'PlatformID': [u'7066191365225244112'], u'Platform': [u'Comcast']}>,

How would I capture the full variable here, including the
at the end?


Escape it in the query string, basically replace the hash with %23.

To answer your question in the comments, yes, there is a template tag that can help you with this. The syntax is

{% url 'some-url-name' arg1=v1 arg2=v2 %}

Or, if you want to escape in code, you have several options in https://docs.djangoproject.com/en/1.10/ref/utils/#module-django.utils.encoding