我想要完成的是从URL获取URL参数值
http://127.0.0.1:8000/sample/redirect_login/?request_token=9I0KoKcgdKH0s6w1Qzp6t5P2czlyxPum&action=login&status=success
我在urls.py中创建了类似的网址路径,但看起来不匹配
path('redirect_login/?request_token=<str:request_token>&action=<str:action>&status=<str:status>',views.redirectLogin, name = "redirectLogin"),
我想获取参数1. request_token 2. action 3. Status
请帮忙怎么做?我应该使用REGEX进行网址匹配吗?
由于
答案 0 :(得分:2)
在urls.py中你应该这样做:
path('redirect_login/',views.redirectLogin, name = "redirectLogin"),
然后在视图中获取参数:
request_token = request.GET.get('request_token', '')
action = request.GET.get('action', '')
status = request.GET.get('status', '')