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 6033819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:32:21+00:00 2026-05-23T05:32:21+00:00

I am attempting to define a search url using Django with the following structure

  • 0

I am attempting to define a search url using Django with the following structure

www.example.com/afdata/search?device=television&category=news&query=channel&limit=30/

My goal is to extract the values television, news, channel and 30 from the above url and pass it to a view defined as follows

def search(request, device='all', category='single', query='', limit=30):
    return HttpResponse("device=%s, category=%s, query=%s, limit=%d", device, category, query, limit)

afdata is the app and in the url configuration file I defined the url as follows:

from django.conf.urls.defaults import *

urlpatterns = patterns('afdata.views',
    (r'^$', 'index'),
    (r'^search?device=(?P<device>.*)&category=(?P<category>.*)&query=(?P<query>.*)&limit=(?P<limit>d+)/$', 'search')
)

When I run using the above search query in the browser, I get 500 Internal Server Error. index responds fine. Any suggestions on what I may be doing wrong?

  • 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-23T05:32:22+00:00Added an answer on May 23, 2026 at 5:32 am

    i suggest that you change your search url to:

    (r'^search', 'search')
    

    then in your view do

    def search(request):
        device = request.GET.get('device', 'all')
        category = request.GET.get('category', 'single')
        query = request.GET.get('query', '')
        limit = request.GET.get('limit', 30)
    
       return HttpResponse("device=%s, category=%s, query=%s, limit=%d", device, category, query, limit)
    

    This is much more robust and changeable and flexible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using jquery validation plugin and i'attempting to define a rule for the only
I'm attempting to define an extremely simple utility method that will save me from
I'm attempting to use the #define directive to change all of ulong to unsigned
Attempting to use the data series from this example no longer passes the JSONLint
I'm attempting to define an eclipse plugin product that includes bundles from Spring's Enterprise
I'm attempting to compile a working copy of the MagickNet class library (DLL) using
My program is attempting to draw grammars in C# & WPF. I have: 1
I am attempting to use a full text search over a series of names
I am currently attempting to define a function based on a compiler flag. If
I'm attempting to use a /D compiler option on MSVC6 to define a string,

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.