encode url

22 views
Skip to first unread message

Pnelson

unread,
Mar 31, 2015, 12:43:14 PM3/31/15
to django...@googlegroups.com

Im trying to learn django and i have a form in html that have 3 arguments (app_id,user_id and username) and i want to encode those 3 arguments in base64.

views.py

def encode(self):
        return base64.b64encode()

def decode(self):
        return base64.b64decode()

login.html

<body>
<form action="/notification_html/" method="get">
    Application ID: <input type="text" name="appid">
    User ID: <input type="text" name="userid">
    Username: <input type="text" name="username">
    <input type="submit" value="Login">
    <input type="reset" value="Reset">
</form>
</body>

URL created: http://127.0.0.1:8000/notification_html/?appid=1&userid=&username=1

Any suggestion to encode the url?

Thanks for help


Vijay Khemlani

unread,
Mar 31, 2015, 1:29:12 PM3/31/15
to django...@googlegroups.com
you want to encode them before they are submitted to the server? why?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5651af5b-9878-4c52-92a0-6ac32e1610dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ilya Kazakevich

unread,
Apr 1, 2015, 9:19:55 PM4/1/15
to django...@googlegroups.com
Why do you need it?

Web-browser encodes your data using Percent-encoding (http://en.wikipedia.org/wiki/Percent-encoding) by default. 

You may base64 your code on client side using JS and decode it on server side using python, but it seems useless for me. base64 is used to eliminate special chars, but percent-encoding helps your to escape special chars, so you do not need to worry about escaping. 
Reply all
Reply to author
Forward
0 new messages