I am a beginner in Django. When I run my program I got the following error.
Exception Type: ViewDoesNotExist
Exception Value:
Could not import polls.views.output. View does not exist in module polls.views.
I have a search Function in my view:
def search(request):
c = {}
c.update(csrf(request))
if request.method == 'POST': # If the form has been submitted...
form = Search(request.POST) # A form bound to the POST data
if form.is_valid():
search_query=form.cleaned_data['query']
pi=add.add(search_query)
return render_to_response('polls/output.html',{'pi': pi}) # Redirect after POST
else:
form=Search()
return render_to_response(request, 'polls/search.html', c.update(form=form))
output.html
<ul>
{% for p in pi %}
<li>{{p}}</li>
{% endfor %}
</ul>
Can you please help me?
Here is my url file. I updated it. But, now it tells me syntax error at url.py file:
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.foo.urls')),
url(r'^polls/output$', 'polls.views.search')
url(r'^polls/search$', 'polls.views.search'),
url(r'^polls/$', 'polls.views.index'),
url(r'^polls/(?P<poll_id>\d+)/$', 'polls.views.detail'),
url(r'^polls/(?P<poll_id>\d+)/results/$', 'polls.views.results'),
url(r'^polls/(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)