2011-12-15 5 views
0

나는 a부터 f까지의 열이있는 테이블이 있습니다.보기에서 값순 정렬 저장

난 후 열을 정렬하는 정렬 박스를 가지고 등 중량, 위치, 눈 색깔 등의

각 중량, 위치, 눈 색깔별로 F를 통해, 예를 들면 시작 값을 갖고, 없음.

이제 값을 None에서 "50-100", "Korea", "Hazel"로 변경할 수 있습니다.

페이지를 새로 고치거나 정렬이 필요한 열을 변경하려는 경우 값 정렬 기준을 없음으로 되돌리려면 어떻게해야합니까? Heres는

템플릿 코드의 작은 예 :

<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..... 

내보기

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 

답변

0

의 샘플 조각 당신은 상태를 저장하는 방법이 필요합니다. 많은 자습서를 읽고, 당신은 항상에도 불구하고, 사전

sort = request.session.get('sort', None) 
+0

같은 액세스를

request.session['sort'] = 'my_sort_value' 

다른보기에서 검색하려면 :

가장 간단한 방법은 session에 정보를 저장하는 것입니다 다시 읽을 때도 부품을 놓치게됩니다. 이것은 내가 놓친 것들 중 하나였습니다. 건배 –

관련 문제