I am not a Django expert by any mean, but I don't think (r'', include('django.contrib.flatpages.urls')) works, since the regex is empty...
Regards,
Phil
On Tuesday, July 30, 2013 1:02:53 PM UTC-3, Robin Lery wrote:
-- On Tuesday, July 30, 2013 1:02:53 PM UTC-3, Robin Lery wrote:
---------- Forwarded message ----------
From: Robin Lery <robi...@gmail.com>
Date: Tue, Jul 30, 2013 at 9:22 PM
Subject:
To: django...@googlegroups.comHello,I am stuck at a point where i should be able to type in a search query on the page and it django should get back a list of matching pages if any. But it doesnt show me any pages, even though its there, and gives me an erros:Page not found (404)
Request Method: GET Request URL: http://127.0.0.1:8000/search/? csrfmiddlewaretoken= W6n1O1vQCMyDojxEkR4mPnRrVz9lYV t1&q=one No FlatPage matches the given query.
Please point me as to where am doing wrong. Thank you.my views.py:from django.http import HttpResponsefrom django.template import loader, Contextfrom django.contrib.flatpages.models import FlatPage def search(request):query = request.GET['q']resuts = FlatPage.objects.filter(content__icontains=query) template = loader.get_template('search/search.html') context = Context({'query':query,'resuts':resuts})response = template.render(context)return HttpResponse(response)urls.py:from django.conf.urls import patterns, include, urlfrom django.contrib import adminadmin.autodiscover()urlpatterns = patterns('',url(r'^admin/', include(admin.site.urls)),(r'^tinymce/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': 'C:/Users/Kakar/web/cms/static/js/tinymce/' }), (r'', include('django.contrib.flatpages.urls')), (r'^search/$', 'search.views.search'),)settings.py:In the installed-apps, I have installed 'search'.default.html:<html><head><title>{{ flatpage.title }}</title></head><body><form method="get" action="/search/">{% csrf_token %}<p><label for="id_q">Search:</label><input type="text" name="q" id="id_q" /><input type="submit" value="Submit" /></p></form><h1>{{ flatpage.title }}</h1>{{ flatpage.content }}</body></html>search.html:<html><head><title>Search</title></head><body><p>You searched for "{{query}}"; the results are listed below.</p>{% if results %}<ul>{% for page in results %}<li><a href="{{page.get_absolute_url}}">{{page.title}}</a> </li>{% endfor %}</ul>{% else %}<p>No results.</p>{% endif %}</body></html>
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment