4

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<field>\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?

1 Answer 1

6

Don't do this.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.