如何从请求中提取值?

I would like to extract the division data from the URL

path("company/<division>/authenticate", views.user_info, name="user_info")

我试图这样做,但没有用

@api_view(["GET", "POST"])
def user_info(request):
    if request.method == "GET":
        data = {
            "username": request.GET.get("username"),
            "password": request.GET.get("password"),
            "division": request.GET.get("division"),
        }
        return JsonResponse(data)

你能帮忙吗?

评论