Inside this code I have an ‘args’ value which is ‘title.title’, this value displays in my URL.
How do I make the url read like this: “index.html/something_something” instead how how it displays now, which is: “index.html/something%20something”.
def livesearch():
'''Auto completes the search query'''
partialstr = request.vars.partialstr
query = db.listing.title.like('%'+partialstr+'%')
titles = db(query).select(db.listing.ALL)
items = []
for title in titles:
items.append(DIV(A(title.title, _id="resultLiveSearch", _href=URL('search', args='%s' % title.title))))
return TAG[''](*items)
I tried making it:
_href=URL('search', args='%s' % title.title.replace("%20","_")
Which I thought would work, but it didn’t, what am I doing wrong? How can I fix this?
Thank you.
The
%20is a replacement for a single white space, so you should replace spaces with underscores before passing them toURL: