I'm constructing the urlconf for a website but I'm facing a couple of issues;
At some point I have to present a list of tasks which can eventually be reordered. The problem is that I have no clue on how to go about configuring the regex.
So far I've got this:
url(r'^myapp/mytasks, myview.tasks),
The default behavior is to accept requests at www.mydomain.com/myapp/mytasks.
However should the order button be pressed by a user, I need Django to also accept requests of type:
www.mydomain.com/myapp/mytasks/sort_by/price_highest
www.mydomain.com/myapp/mytasks/sort_by/price_lowest
but not
www.mydomain.com/myapp/mytasks/price_lowest
Is there a regex for this scenario?
Thank you all in advance.
P.S Ideally I would also like to know how I could possibly reverse them.
url(r'^myapp/mytasks/sort_by', myview.tasks),www.mydomain.com/myapp/mytasks.www.mydomain.com/myapp/mytasks?sort_by=price_highest, or evenwww.mydomain.com/myapp/mytasks&sort_by=price&reversed=false. You'd then have to process the query string inside the view.url(r'^myapp/mytasks(?!/price_lowest)', myview.tasks)price_lowest. I needprice_lowestorprice_highestor whatever other parameter comes to my mind but only after/sort_by/exists. Ifsort_byis absent, discard all and revert to default.