Django and query string parameters

后端 未结 3 1072
终归单人心
终归单人心 2020-12-08 04:15

Assuming I have a \'get_item\' view, how do I write the URL pattern for the following php style of URL?

http://example.com/get_item/?id=2&type=foo&co         


        
3条回答
  •  醉酒成梦
    2020-12-08 04:36

    See this pattern

    url(r'^get_item$', get_item)
    

    And your view will look like

    def get_item(request):
        id = int(request.Get.get('id'))
    

提交回复
热议问题