I am developing a search form in web2py, I create the form like this 

    <table>    
    <form method="post" action="{{=URL('views', 'search')}}">
        <tr><td><label>Enter Keywords</label></td><td><input 
style="background-color: lightgreen; color:#333; font-weight:bold; 
width:260px;" type="text" name="tags"></td>
            </tr>
            <tr>
            <td>
            <label>Select Region</label>
                </td>
                <td>
                    <select name="region" style="width:260px">
        <option value="" style="background-color: darkgreen; color:#FEFEFE; 
font-weight:bold; width:260px;">Choose a Region...
    
        {{for region in region_query:}}
        <option value="{{=region.id}}" style="background-color: lightgreen; 
color:#333; font-weight:bold; width:260px;">{{=region.title}}</option>
        {{pass}}
        </select>
        </td>
        </tr>
        <tr>
                <td>
            <label>Select Category</label>
                </td>
        <td>
        
        <select name="category" style="width:260px;">
        
        <option value="" style="background-color: darkgreen; color:#FEFEFE; 
font-weight:bold; width:260px;">Choose a Category
        {{for cat in cat_query:}}
        <optgroup label="{{=cat.title}}" style="background-color: 
darkgreen; color:#FEFEFE; font-weight:bold; width:260px;">
        {{sub_query = db(db.sub_category.main_category == 
cat.id).select(orderby=db.sub_category.title)}}
        </optgroup>
        {{for sub in sub_query:}}
        <option value="{{=sub.id}}" style="background-color: lightgreen; 
color:#333; width:260px;">{{=sub.title}}</option>
        
        {{pass}}
        {{pass}}
        </select>
        
        
        
        </td>
        </tr>
        <tr>
    <td colspan="2" align="right">
        <input type="submit" style="background-color: lightgreen; 
color:#333; font-weight:bold; width:260px; height:30px" value="Search 
Business Directory">
        </td>
        </tr>
    </form>
    </table>

My controller consists of this

    def search():
        mystr = str(request.post_vars["tags"])
        if mystr == "" or mystr == None:
            return redirect(URL('default', 'error_search'))
        region = str(request.post_vars["region"])
        if region == "" or region == None:
            return redirect(URL('default', 'error_search'))
        category = str(request.post_vars["category"])
        if category == "" or mystr == None:
            return redirect(URL('default', 'error_search'))
        featured = db((db.featured_listing.tag_words.like('%'+mystr+'%')) | 
(db.listing.region.contains(region)) | 
(db.listing.sub_category.contains(category))).select(orderby=db.featured_listing.title)
        query = (db.listing.tag_words.like('%'+mystr+'%')) | 
(db.listing.region.contains(region)) | 
(db.listing.sub_category.contains(category))
        orderby = db.listing.title
        pcache = (cache.ram, 15)
        paginate = Pagination(db, query, orderby, display_count=10, 
cache=pcache, r=request, res=response)
        search_query = paginate.get_set(set_links=True)
        return dict(search_query=search_query, featured=featured)

My view for the resultant search contains this 


    {{for query2 in 
featured:}}                                                                     
   

                                                            
        <div class="listingItem">
        <div class="listingItem-content">
            <h2>{{=query2.title}}</h2>
        ....

etc etc

I receive this error when searching

    Traceback (most recent call last):
      File "/var/www/web2py/gluon/restricted.py", line 212, in restricted
        exec ccode in environment
      File 
"/var/www/web2py/applications/GreenPages_web/views/views/search.html", line 
47, in <module>
    AttributeError: 'Row' object has no attribute 'title'


Any idea how I can fix this and achieve the results I am looking for, I 
think how I am implementing the search isn't right would appreciate any 
help *cheers.

Thank you for any advice given.


-- 



Reply via email to