Have you read this section: 
http://web2py.com/books/default/chapter/29/6#One-to-many-relation? (Think 
person=group and dog=event.)

On Wednesday, June 27, 2012 12:42:40 PM UTC-4, Alec Taylor wrote:
>
> I was planning to have a many groups to 1 event relation, but now that 
> I think of it, there are better ways of accomplishing that. 
>
> How do I do the n+1 unrolling simply? 
>
> I.e.: how do I create a list using SQLFORM (or similar) which finds 
> and displays in a list all [events in [db.event for each group in 
> db.group_of_events]]?` 
>
> On Thu, Jun 28, 2012 at 2:34 AM, Anthony wrote: 
> > Actually, why do you need the "events" field in group_of_events? If you 
> want 
> > a one-to-many relation with db.event, you've already got it with the 
> > db.event.group_id field. What workflow are you trying to create? 
> > 
> > Anthony 
> > 
> > 
> > On Wednesday, June 27, 2012 12:09:50 PM UTC-4, Alec Taylor wrote: 
> >> 
> >> Thanks, that fixed some other problems, but my initial problem of not 
> >> getting the list of events associated with each group is still 
> >> present. 
> >> 
> >> >> db.define_table( 
> >> >>     'group_of_events', 
> >> >>     Field('group_name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 
> >> >> 'group_of_events.group_name')]), 
> >> >>     Field('events', 'list:reference db.event', 
> requires=[IS_IN_DB(db, 
> >> >> 'event.id', '%(event_name)s [%(group_id)s]', multiple=True)]) 
> >> > 
> >> > 
> >> > When you put the IS_IN_DB validator in a list, you do not get the 
> >> > standard 
> >> > dropdown (for single items) or multiple select widget (for multiple 
> >> > items). 
> >> > Change the above to: 
> >> > 
> >> >     requires=IS_IN_DB(db, 'event.id', '%(event_name)s 
> [%(group_id)s]', 
> >> > multiple=True) 
> >> > Anthony 
> >> > 
> >> > -- 
> >> > 
> >> > 
> >> > 
> > 
> > -- 
> > 
> > 
> > 
>

Reply via email to