UPDATION: I have updated my post with images, please see now what I exactly want :
My front_page:
user hase entered the word 'name'.
after the user presses search, the user is getting the list and charts , but you can see that the word 'name' is more retained in the search bar but I want it to be there.
Now did you get my question ?
My views.py file code:
#!/usr/bin/python
from django.core.context_processors import csrf
from django.template import loader, RequestContext, Context
from django.http import HttpResponse
from search.models import Keywords
from django.shortcuts import render_to_response as rr
import Cookie
def front_page(request):
if request.method == 'POST' :
from skey import find_root_tags, count, sorting_list
str1 = request.POST['word']
str1 = str1.encode('utf-8')
list = []
for i in range(count.__len__()):
count[i] = 0
path = '/home/pooja/Desktop/'
fo = open("/home/pooja/Desktop/xml.txt","r")
for i in range(count.__len__()):
file = fo.readline()
file = file.rstrip('\n')
find_root_tags(path+file,str1,i)
list.append((file,count[i]))
for name, count1 in list:
s = Keywords(file_name=name,frequency_count=count1)
s.save()
fo.close()
list1 = Keywords.objects.all().order_by('-frequency_count')
t = loader.get_template('search/front_page.html')
c = RequestContext(request, {'list1':list1,
})
c.update(csrf(request))
response = t.render(c)
response.set_cookie('word',request.POST['word'])
return HttpResponse(response)
else :
str1 = ''
template = loader.get_template('search/front_page.html')
c = RequestContext(request)
response = template.render(c)
return HttpResponse(response)
I have created an app using django search that searches the keywords in 10 xml documents and return the frequency of the occurrence of the keywords for each file which is displayed as hyperlinked list of xml documents with their respective counts and the charts.
On running the app on server, as user enters the word in the search bar , the results are displayed on the same page perfectly but the word is not retained in the search bar as user presses search tab . For that to be done, I have made use of cookies but it is giving error
'SafeUnicode' object has no attribute 'set_cookie'
why? I'm new to django, so please help