This is my views.py file
#!/usr/bin/python
from django.template import Context, loader, RequestContext
from django.http import HttpResponse
from skey import find_root_tags, count, sorting_list
from search.models import Keywords
#from django.shortcuts import render_to_response as rr
def front_page(request):
if request.method == 'POST' :
str1 = request.POST['word']
fo = open("xml.txt","r")
for i in range(count.__len__()):
file = fo.readline()
file = file.rstrip('\n')
find_root_tags(file,str1,i)
list.append((file,count[i]))
sorting_list(list)
for name, count in list:
s = Keywords(file_name=name,frequency_count=count)
s.save()
fo.close()
return HttpResponseRedirect('/results/')
else :
str1 = ''
list = []
template = loader.get_template('search/search.html')
c = RequestContext(request)
response = template.render(c)
return HttpResponse(response)
def results(request):
list1 = Keywords.objects.all()
t = loader.get_template('search/results.html')
c = Context({'list1':list1,
})
return HttpResponse(t.render(c))
this is my results.html(which is stored in /home/pooja/Desktop/my_templates/search/results.html, (here search is my app name) :
<html>
<body bgcolor = "#9ACD32">
<style type="text/css">
h1 {
position: absolute;
top: 200px;
left: 480px;
}
form #Edit1 { position: relative;
top: 245px;
left: 480px;
}
form #Edit2 { position: relative;
top: 220px;
left: 680px;
}
</style>
<font size="5" face="arial" color="#0000FF">
<h1>Search Page</h1>
</font>
<hr/>
<br/>
<br/>
<Form Method ="POST">
<div id="Edit1">
<INPUT TYPE = 'text' name ='word' VALUE ="">
</div>
<div id="Edit2">
<INPUT TYPE = "Submit" VALUE = "Search">
</div>
</FORM>
</body>
</html>
When I ran this app on server, the search.html page was coming and as I entered some word say 'book' it gave me this error:
Using the URLconf defined in mysite.urls, Django tried these URL patterns,in this order:
^search/$
^admin/
The current URL, front_page/, didn't match any of these.
Why has this happened? I have my all the skey.py, xml documents and xml.txt stored in search app.