1👍
Query parameters like your sort
and filter
will be passed to your /
route through GET
variable. So your URLconf looks like:
urls.py
...
url(r'^/$',
sorter
),
Note that you don’t put your GET
parameters in your URLconf. Instead, they are parsed in key-value fashion and put in an HTTPRequst object, which gets passed to your view. Your view looks like:
views.py
def sorter(request):
...
and in this view, you can access your GET
parameters through request.GET
. For example, you might use request.GET['sort']
to get the value of the sort
parameter. Because parameters are key/value pairs, you can have essentially as many as you want in any order, and it’s up to the logic of the view to put them into use. You might want to start at Part 4 of the tutorial for an example of request processing, noting that URL query parameters are passed in request.GET
instead of request.POST
.
0👍
try some of the examples in the docs, replacing POST
with GET
in templates and views and see what happens
- [Answer]-How can I get the name of app inside a model?
- [Answer]-Django constant argument on URL
- [Answer]-Django – How to make a Django snipet available to use as template tag?