Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, I don't if <code>encrypt</code> is exactly what you meant. I mean, encrypting a string using say, <code>md5</code> will make impossible to decrypt the string for you on the server side. For this purpose you should go with <code>encode</code>, like using <code>base64</code> encoding system. This will replace the id with an encoded string but someone <code>savvy</code> may notice this and decode the string in your urls.</p> <p>What you're trying to accomplish here is <strong>security through obscurity</strong> which is not recommended. You can apply this technique but you'll be better adding even more security in your code like permissions and stuff like that.</p> <p>For encoding your user id, you can add this method to your <code>Item</code> class:</p> <pre><code>class Item ... def encoded_id(self): import base64 return base64.b64encode(str(self.user_id)) def decode_id(self, id): import base64 return base64.b64decode(id) ... </code></pre> <p>That way you can do this in your views:</p> <pre><code>&lt;tr&gt; {% with user_id=item.encoded_id %} #user_id have to be encrypted &lt;td&gt;&lt;center&gt;&lt;a href="{% url "accounts" user_id %}"&gt;{{ item.Company_name }}&lt;/a&gt;&lt;/center&gt;&lt;/td&gt; {% endwith %} </code></pre> <p>and you will have your urls with the <code>id</code> encoded in base64.</p> <p>Pay attention to my warning before. <strong>You should never rely only on this, this is a valid practice but keep in mind that the encoding can be reversed.</strong></p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload