Do you mean that you want to avoid urls like www.example.com/db-contents/?level=2
? Passing variables in through request.GET like that is the normal way to do it. All the requests will go to the same url and view, and you can just do request.GET['level']
in the template.
If you absolutely want the url to stay completely static (`www.example.com/db-contents/
) then you can send and receive your data via AJAX calls.
by adding ?foo=bar
to the url it means you can access the 'foo' key in the request.GET
dictionary, and the value of that key will be "bar"
. for multiple variables you separate with the &
symbol.
For example:
www.example.com/db-contents/?foo=bar&somevar=1&anothervar=
>>> request.GET['foo']
'bar'
>>> request.GET['somevar']
'1'
>>> request.GET['anothervar']
None
>>> "anothervar" in request.GET
True
>>> "notsetvar" in request.GET
False