开发者

Variable number of fields in Django URL

I'd like a URL of the form:

... field1/eq/value1/field2/gt/value2/ ...

Where I want to filter the contents of the page in the view function based on an arbitrary number of fields (the names of which are not known in advance).

I've tried:

(r'^((?P<fi开发者_运维问答eld>\w+)/(?P<op>[a-z]+)/(?P<value>\w+)/)*$', my_view)

But the keyword arguments are filled with the last set of three field/op/value to occur in the URL.

Is there any way that I could populate a list or dictionary based on a variable number of URl fields like this?

Or should I be doing this some completely different way?


Don't do this.

Use the query string. ?field,eq,value&field,gt,value will work out much better.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜