简体   繁体   中英

How do I match this URL in Django's urls.py?

I want to match a url that:

begins with /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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM