I have a table with columns a through f.
I then have a sorting box which sorts columns a through f by weight, location, eye color etc.
Each of weight, location, eye color etc has a starting value of ,for example, None.
Now, you can change the values from None to say, “50-100”, “Korea”, “Hazel”.
If i want to refresh the page, or change the columns that need sorting, how do i keep the sort by values from reverting to None.
Heres a small example of the template code:
<form action="" method="get">
<div class="sort">
<ul>
<li>
<a>Sort By</a>
</li>
</ul>
<ul>
<li id="sample4" class="dropdown4">
<a href="#">Location | <span4>World Wide</span4></a>
<ul><li><a href="#"><input type="radio" id="radio4" name="Location" value="America"/><label for="radio4">America</label></a>
<a href="#"><input type="radio" id="radio5" name="Location" value="Zanzibar"/><label for="radio5">Zanzibar</label></a>
<a href="#"><input type="radio" id="radio6" name="Location" value="Aussie"/><label for="radio6">Aussie</label></a>
<a href="#"><input type="radio" id="radio7" name="Location" value="Disneyland"/><label for="radio7">Disneyland</label></a>
<a href="#"><input type="radio" id="radio8" name="Location" value="Someplace"/><label for="radio8">Someplace</label></a>
<a href="#"><input type="radio" id="radio9" name="Location" value="TheOcean"/><label for="radio9">The Ocean</label></a>
</li></ul>
</li>
</ul>
etc.....
and a sample snippet of my view
arguments = {}
if request.method == 'GET':
sortlocation = request.POST.getlist('Location')
else:
pass
if sortlocation == []:
sortlocation = "World Wide"
else:
sortlocation = sortlocation[0]
pass
if sortlocation is not "World Wide":
arguments['Location'] = sortlocation
else:
arguments['Location__isnull'] = False
You need a way to store state.
The simplest way is to store that information in the session:
To retrieve it in any other view, access it like a dictionary