Problem overview:
At the beginning, the requirement was to receive parameters through the URL, but it has always adhered to the way of receiving parameters through regular expressions, that is, in the form of (?P<parm>.+) .
Later, it was found that (/?) can be matched at http://regex101.com and successfully obtained the parameters. However, in Django, the symbol "?" is a reserved field, and this method failed.
Reference URL:
https://stackoverflow.com/questions/4162625/django-request-get-parameters
Solution:
【1】
Crawling the article found that request.GET['keyname ' ] or request.GET.get( ' keyname ' , default_value) can directly get the parameters in the URL
There is no need to match the regular expression of urls.
【2】
Of course, it can also be solved by try and except.
from django.utils.datastructures import MultiValueDictKeyError try: key_you_want = request.GET['keyname'] except MultiValueDictKeyError: key_you_want = None
Finally, hee hee!