Re: [web2py] Re: list:reference database selection
Always good to help :) On Thursday, September 20, 2012 5:46:01 PM UTC+1, Andrew Evans wrote: > > OMG You are a genius! > > That worked and worked beautifully > > thank you so much > > *cheers > > Andrew > > On Thu, Sep 20, 2012 at 9:43 AM, villas >wrote: > >> Not sure I read your question carefully enough, but maybe you need >> something like: >> >> query = db.listing.region.contains(region) >> >> Anyhow, contains has a special usage for list fields. >> >> >> On Thursday, September 20, 2012 5:07:46 PM UTC+1, Andrew Evans wrote: >> >>> I have since added format='%(title)s %(id)s' to the region table but the >>> listing is not being selected >>> >>> Is it because it is a list? >>> >>> I have entered multiple region entries for a single listing any idea how >>> to select that listing in each of those regions when using the region >>> search method? >>> >>> *cheers >>> >>> and ty >>> >>> >>> >>> On Thu, Sep 20, 2012 at 7:53 AM, Andrew Evans wrote: >>> Hello I have a field in my table defined like so Field('region', 'list:reference region'), The data entered is multiple regions in the form, Gibsons, Sechelt I am wondering since it is not an id how I can pass the name of the town as an argument, so it only selects entries from that town this is the view from the search_methods/region page {{for region in region_query:}} >>> target="_blank" data-transition="fade" title="{{=region.title}}" >{{=region.title}} {{pass}} I need to change the *a* tag I think here so I can pass the correct argument here is the controller function for the views/region page (where the above a tag points to) not sure what to change here any ideas are greatly appreciated def region(): region = request.args(0) query = db.listing.region == region orderby = db.listing.title pcache = (cache.ram, 15) paginate = Pagination(db, query, orderby, display_count=10, cache=pcache, r=request, res=response) region_query = paginate.get_set(set_links=**True) region_text = db(db.region.id == region).select() return dict(region_query = region_query, region_text=region_text) *cheers and ty Andrew >>> >>> -- >> >> >> >> > > --
Re: [web2py] Re: list:reference database selection
OMG You are a genius! That worked and worked beautifully thank you so much *cheers Andrew On Thu, Sep 20, 2012 at 9:43 AM, villas wrote: > Not sure I read your question carefully enough, but maybe you need > something like: > > query = db.listing.region.contains(region) > > Anyhow, contains has a special usage for list fields. > > > On Thursday, September 20, 2012 5:07:46 PM UTC+1, Andrew Evans wrote: > >> I have since added format='%(title)s %(id)s' to the region table but the >> listing is not being selected >> >> Is it because it is a list? >> >> I have entered multiple region entries for a single listing any idea how >> to select that listing in each of those regions when using the region >> search method? >> >> *cheers >> >> and ty >> >> >> >> On Thu, Sep 20, 2012 at 7:53 AM, Andrew Evans wrote: >> >>> Hello I have a field in my table defined like so >>> >>> Field('region', 'list:reference region'), >>> >>> The data entered is multiple regions in the form, Gibsons, Sechelt >>> >>> I am wondering since it is not an id how I can pass the name of the town >>> as an argument, so it only selects entries from that town >>> >>> this is the view from the search_methods/region page >>> >>> >>> {{for region in region_query:}} >>> >> target="_blank" data-transition="fade" title="{{=region.title}}" >>> >{{=region.title}} >>> {{pass}} >>> >>> >>> I need to change the *a* tag I think here so I can pass the correct >>> argument >>> >>> here is the controller function for the views/region page (where the >>> above a tag points to) not sure what to change here any ideas are greatly >>> appreciated >>> >>> def region(): >>> region = request.args(0) >>> query = db.listing.region == region >>> orderby = db.listing.title >>> pcache = (cache.ram, 15) >>> paginate = Pagination(db, query, orderby, display_count=10, >>> cache=pcache, r=request, res=response) >>> region_query = paginate.get_set(set_links=**True) >>> region_text = db(db.region.id == region).select() >>> >>> return dict(region_query = region_query, region_text=region_text) >>> >>> *cheers >>> >>> and ty >>> >>> Andrew >>> >> >> -- > > > > --
[web2py] Re: list:reference database selection
Not sure I read your question carefully enough, but maybe you need something like: query = db.listing.region.contains(region) Anyhow, contains has a special usage for list fields. On Thursday, September 20, 2012 5:07:46 PM UTC+1, Andrew Evans wrote: > > I have since added format='%(title)s %(id)s' to the region table but the > listing is not being selected > > Is it because it is a list? > > I have entered multiple region entries for a single listing any idea how > to select that listing in each of those regions when using the region > search method? > > *cheers > > and ty > > > > On Thu, Sep 20, 2012 at 7:53 AM, Andrew Evans > > wrote: > >> Hello I have a field in my table defined like so >> >> Field('region', 'list:reference region'), >> >> The data entered is multiple regions in the form, Gibsons, Sechelt >> >> I am wondering since it is not an id how I can pass the name of the town >> as an argument, so it only selects entries from that town >> >> this is the view from the search_methods/region page >> >> >> {{for region in region_query:}} >> > target="_blank" data-transition="fade" title="{{=region.title}}" >> >{{=region.title}} >> {{pass}} >> >> >> I need to change the *a* tag I think here so I can pass the correct >> argument >> >> here is the controller function for the views/region page (where the >> above a tag points to) not sure what to change here any ideas are greatly >> appreciated >> >> def region(): >> region = request.args(0) >> query = db.listing.region == region >> orderby = db.listing.title >> pcache = (cache.ram, 15) >> paginate = Pagination(db, query, orderby, display_count=10, >> cache=pcache, r=request, res=response) >> region_query = paginate.get_set(set_links=True) >> region_text = db(db.region.id == region).select() >> >> return dict(region_query = region_query, region_text=region_text) >> >> *cheers >> >> and ty >> >> Andrew >> > > --
[web2py] Re: list:reference database selection
I have since added format='%(title)s %(id)s' to the region table but the listing is not being selected Is it because it is a list? I have entered multiple region entries for a single listing any idea how to select that listing in each of those regions when using the region search method? *cheers and ty On Thu, Sep 20, 2012 at 7:53 AM, Andrew Evans wrote: > Hello I have a field in my table defined like so > > Field('region', 'list:reference region'), > > The data entered is multiple regions in the form, Gibsons, Sechelt > > I am wondering since it is not an id how I can pass the name of the town > as an argument, so it only selects entries from that town > > this is the view from the search_methods/region page > > > {{for region in region_query:}} > target="_blank" data-transition="fade" title="{{=region.title}}" > >{{=region.title}} > {{pass}} > > > I need to change the *a* tag I think here so I can pass the correct > argument > > here is the controller function for the views/region page (where the above > a tag points to) not sure what to change here any ideas are greatly > appreciated > > def region(): > region = request.args(0) > query = db.listing.region == region > orderby = db.listing.title > pcache = (cache.ram, 15) > paginate = Pagination(db, query, orderby, display_count=10, > cache=pcache, r=request, res=response) > region_query = paginate.get_set(set_links=True) > region_text = db(db.region.id == region).select() > > return dict(region_query = region_query, region_text=region_text) > > *cheers > > and ty > > Andrew > --