[Answer]-Recalling/displaying last session

1👍

✅

Instead of having tick, you may have a list of tick. And if you want to get the last tick, just get the last element of the list.

result = {}

context = RequestContext(request)

t = request.session.get("tick")

if request.method == 'POST':
    search = Search(data=request.POST)

tick_list = None
if search.is_valid():

    ticker = search.cleaned_data['search']
    tick_list =request.session.get('tick_list',[])
    tick_list.append(tick)
    request.session["tick_list"] = tick_list

else:
    print search.errors
else:
    search = Search()
//here send the tickest to the template
return render_to_response('ui/search.html', {"result":result,'tick_list':tick_list}, context)

Then in your template, "search.html" to display the tickets: use {{tick_list}}

Leave a comment