How do I match this URL in Django's urls.py?
I want to match a url that:
begins with /开发者_StackOverflow社区signup
and ends with password=goodbye
That's it. If something begins with that and ends with that, how do I match that in regex?
I understand that I should do this in urls.py, but I have to because of certain reasons.
Please answer how I would match it this way. I have to because a iPhone client (which cannot be changed) hardcoded it this way. I know it's not ideal, but I have to match it this way now.
Don't ever send passwords in the URL. They belong in the POST body, which is not stored by browsers (you can repeat POSTs in browsers, but POST data is not stored in the history).
(r'^/signup/(.*)password=goodbye$', ...
You should just match for /signup
. You can get the password through the request object:
//Your url handler:
def signup_handler(request):
password = request.GET["password"]
...
But you shouldn't be passing the password as a GET argument...
you can have something like this in your urls.py :
(r'^/signup/password=(?P<password>.*)/$, signup_action)
and in your views.py you have :
def signup( request, password ):
.....
PS : it not a good idea to pass password in url
精彩评论