如何从 Django 中的 GET 参数创建漂亮的 url?

How do I create pretty url from the GET parameters in Django?

我的查询字符串是由带有姓名和年龄的表单生成的,看起来像这样,

www.example.com/?name=Martin&age=19&place=RU

表格,

<form action="" method="get">
  Name: <input type="text" name="name"><br>
  Age: <input type="text" name="age"><br>
  Place <input type="text" name="place"><br>
  <input type="submit" value="Submit">
</form>

我想把提交给 django 的 url 变成

www.example.com/Martin/19/RU

我该怎么做?我应该在 formurls.py 上修改什么?

谢谢

<script>
function changeAction() {

var profile_form = document.getElementById('profileform');
        if(profile_form) {
        var txt = "http://www.example.com/";
        var i;
        for (i = 0; i < profile_form.length; i++) {
            txt = txt + profile_form.elements[i].value + "/";
        }
           profile_form.action = txt; 
        }}
</script>

在你的 html 中,你需要这样的东西:

<form action="" method="get" id="profileForm" onsubmit="changeAction()">
  Name: <input type="text" name="name"><br>
  Age: <input type="text" name="age"><br>
  Place <input type="text" name="place"><br>
  <input type="submit" value="Submit">
</form>

我想这应该可以解决问题。