Python regex with question mark literal

前端 未结 5 1261
耶瑟儿~
耶瑟儿~ 2020-12-06 17:30

I\'m using Django\'s URLconf, the URL I will receive is /?code=authenticationcode
I want to match the URL using r\'^\\?code=(?P.*)$\'

5条回答
  •  情歌与酒
    2020-12-06 17:59

    Django's urls.py does not parse query strings, so there is no way to get this information at the urls.py file.

    Instead, parse it in your view:

    def foo(request):
       code = request.GET.get('code')
       if code:
          # do stuff
       else:
          # No code!
    

提交回复
热议问题