gpt4 book ai didi

python - django查看方法签名是否可以匹配GET参数?

转载 作者:行者123 更新时间:2023-12-01 05:11:05 25 4
gpt4 key购买 nike

是否可以在以下之间进行匹配:

中的 urls 正则表达式定义 urls.py:

...
url(r'^edit_notification/(?P<foo>\d+)/$', 'edit_notification')
...

views.py:中的方法签名

def edit_notification(request, foo):
...

Django 中的 GET 参数?

或者唯一的方法是外部内部方法 request.GET.get('foo')

最佳答案

GET 参数 are not matched by the url configuration :

What the URLconf searches against The URLconf searches against the requested URL, as a normal Python string. This does not include GET or POST parameters, or the domain name.

它们是HttpRequest对象的一部分,并保存在request.GET查询字典

def edit_notification(request):
foo = request.GET.get('foo')
...

关于python - django查看方法签名是否可以匹配GET参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24214987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com