Django add an item with some additional values

I recently posted a question and now you need a different answer based on the change that needs to be done based on additional parameters.

I used to have the following, which gave me the correct signature.

signature = hashlib.sha1("i=myusername&v=%s&t=7087db23de5ef07b5723" % timestamp)

Now I need to add the following to this line exactly as shown below: % 3D represents =

the problem is by simply adding to the line below django is looking for a different value.

&p=myvar%3Dmyvalue

I tried several versions and it seems to get the wrong value every time. the signature is not my strength, thanks for the help.

signature = hashlib.sha1(u'i=myusername&p=myvar%s%s&v=%s&t=7087db23de5ef07b5723' % ('%3D', myvalue, timestamp))
+3
source share
1 answer

Use %%in format string to get character%

'&p=myvar%%3D%s' % 'value'

I hope I understand you.

You can also use urllib.urlencode

>>>urllib.urlencode({'i':'fundedbyme', 'p':'myvar=%s' % myvalue})
'i=fundedbyme&p=myvar%3Dmyvalue'
+3
source

All Articles