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?