Search code examples
pythondjangourlencryptionsigner

Django signer value


Im trying to encrypt a django model pk to send it via url from a template using django signer :

signer = Signer()
value = signer.sign(pk)
url = {% myapp:url value %}

But i get in my url the pk plus the signature, like this example (pk=110) :

'110:EkfQJafvGyiofrdGnuthdxImIJw'

What i want it's only to retrieve the signature without the pk (110 or any value i send).

Any idea how ?, or any other way to encrypt the pk without using anothe field in the model ??

Thanks in advance


Solution

  • Try first with a django filter for pk's signature and read the urls documentation for passing the pk and signature to the view

    https://docs.djangoproject.com/en/1.11/topics/http/urls/#including-other-urlconfs