开发者

Django url pattern to retrieve query string parameters

I was about ready to start giving a 开发者_如何学Gojqgrid in a django app greater functionality (pagination, searching, etc). In order to do this it looks as though jqgrid sends its parameters in the GET to the server. I plan to write an urlpattern to pull out the necessary stuff (page number, records per page, search term, etc) so I can pass it along to my view to return the correct rows to the grid. Has anyone out there already created this urlpattern I am in search of?

Thanks much.


The answer to this was simpler than I realized. As stated in Chapter 7 of the djangobook in the section titled "Query string parameters" one can simply do something as follows, where "someParam" is the parameter in the query string you want to retrieve. However, Django is designed to be clean in that address bar at the top of the page so you should only use this option if you must.

The query string might look something like this.

http://somedomainname.com/?someString=1

The view might look like this.

def someView(request):
    if 'someParam' in request.GET and request.GET['someParam']:
        someParam = request.GET['someParam']

Hopefully this is of some help to someone else down the road.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜