Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6215653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:05:45+00:00 2026-05-24T07:05:45+00:00

I have intended to write an search application by Django. I am getting a

  • 0

I have intended to write an search application by Django.
I am getting a NoReverseMatch error when I redirect to results page.
I posted my codes here http://pastebin.com/AL4rG9NU

Or you can read it below

urls.py

urlpatterns = patterns('pylucene.views',
    (r'^$', 'index'),
    (r'^search/$', 'search'),
)

views.py

def index(request):
     return render_to_response('pylucene/index.html', context_instance=RequestContext(request))


def search(request):
    query = request.POST['query']
    search_results = search_files(query)
    return HttpResponseRedirect(reverse('pylucene.views.results', args=(search_results,))) 

The Error:

NoReverseMatch at /pylucene/search/
 Reverse for 'pylucene.views.results' with arguments
 '([(u'Documents\\Dieu khien may tinh bang y nghi.txt', u'Dieu khien
 may tinh bang y nghi.txt'), '1 total matching documents.'],)' and
 keyword arguments '{}' not found.
def results(request, search_results):
return render_to_response('pylucene/results.html', {'search_results': search_results}, context_instance=RequestContext(request))

I read several similar topics but I can not solve my problem.
Please help me.
Thank you so much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:05:46+00:00Added an answer on May 24, 2026 at 7:05 am

    I think that you are not undestanding how the reverse function works and what are you trying is just not posible.

    For the reverse function your url must be declared on urls.py for example:

    #urls.py:
    urlpatterns = patterns('blog.views',
        (r'^$', 'index'),
        url(r'^blog/(?P<slug>\d{4})/$', 'blog', name="blog-detail"),
    )
    

    Now in your code you can do

    reverse('blog-detail', args=('django-urls',))
    # the resolt of this is
    # /blog/django-urls/
    

    And this is how reverse works.


    The real answer

    I think that you do not need 2 views, but if you really want to: you have to do this to pass all the query already performed

    def search(request):
        query = request.POST['query']
        search_results = search_files(query)
        return results(request, search_results)
    

    but i think that the best that you can do is this (using GET):

    def search(request):
        query = request.GET['query']  # I think using get is better because you are GETing info
        search_results = search_files(query) # better if returns a generator
        return render_to_response('pylucene/results.html',
                                  {'search_results': search_results},
                                  context_instance=RequestContext(request) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page that is intended to be loaded on a person's
I have a wrapper generic class that intended to be used with a set
I have an UPDATE statement that's intended to update a status field for a
I have a SoapExtension that is intended to log all SOAP requests and responses.
I have found the following expression which is intended to modify the id of
I have a class which is intended for immutable use, hence I would like
I intended to create a class which only have static members and static functions.
I have a few simple scripts that are intended to daisy chain together to
I have a program which only needs a NotifyIcon to work as intended. So
I have a web server located in Switzerland and it is intended to serve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.