【问题标题】:directing based on GET request parameters in django基于 django 中的 GET 请求参数进行定向
【发布时间】:2012-04-20 04:37:53
【问题描述】:

我在 c.html (http://localhost:8000/practice/c) 中,然后单击一个链接将我的 url 更改为

http://localhost:8000/practice/c/?q=1

这是 urls.py

url(r'^$', prac_c),
url(r'^q=\d',fetch_c),

这是views.py

def prac_c(request):
    return render_to_response('subject/c.html', {"problem_list":problem_list})
def fetch_c(request):
        qno = request.GET.get('q')
        if qno:
            return render_to_response('subject/que.html', {'qno':qno}, context_instance=RequestContext(request))

但我没有被定向到 que.html。 urls.py 有问题吗?

【问题讨论】:

    标签: django django-urls


    【解决方案1】:

    URLconf 搜索的内容

    URLconf 搜索请求的 URL,作为一个普通的 Python 字符串。这不包括 GET 或 POST 参数或域名。

    source

    【讨论】:

      猜你喜欢
      • 2023-02-06
      • 1970-01-01
      • 1970-01-01
      • 2016-10-17
      • 2018-11-04
      • 2018-06-26
      • 2017-02-22
      • 1970-01-01
      • 2017-06-08
      相关资源
      最近更新 更多