The problem with many2many is not so much an implementation issues as much as a logical one. There is a reason SQL does not implement APIs for many2many. Django does what it does by considering a only one case of many2many, i.e. when there is no info associated to the link.
think of buyer - purchase - product purchase estabilishes a many2many relation between buyer and product but it also stores information (quantity of the product, price paid, date of purchase, etc.) How should the interface handle the general case? Is there even a general case? Implementing a many2many a la Django without information stored in the links may force developer to make wrong design choices. Massimo On Dec 28, 2:41 pm, Jon <[email protected]> wrote: > Massimo-- > > Thanks! This is fantastic. This is one of the main reasons I like this > framework--it is a tightknit community. > > I am thinking that the new custom form helper will give me enough > insight to build something to handle my many-to-many form field needs. > My vision from an automated perspective would be that you could do an > "IS_IN_DB" referencing a many-to-many relationship and specify > something like "checkbox" or "multi-select list" to have it built with > the SQLFORM command (and handle the many-to-many join table data...). > But I will see if I can get by with the custom form for now. > > Jon > > On Dec 28, 2:43 am, mdipierro <[email protected]> wrote: > > > in trunk now... IS_IN_DB(....orderby=....) > > > Massimo > > > On Dec 27, 10:51 pm, Jon <[email protected]> wrote: > > > > Sounds good. So even for alphabetical sorting, the right approach is > > > to just return my data in the right order via the controller and then > > > have the view iterate through it to build the HTML drop-down manually? > > > If so, that is fine--just confirming best design. > > > > On Dec 27, 2:15 am, mdipierro <[email protected]> wrote: > > > > > You have to do that manually for now. > > > > > On Dec 27, 12:10 am, Jon <[email protected]> wrote: > > > > > > I'd add one follow-up to this to (still need the first answer)... I'm > > > > > curious to know how hard it is to express a many-to-many selection > > > > > (e.g. check all related items that apply to this record's item) in an > > > > > automatically built form? Or do you have to do that manually... > > > > > > On Dec 26, 11:41 pm, Jon <[email protected]> wrote: > > > > > > > I am using this in my model to achieve a drop-down selection in my > > > > > > controller forms, hence views: > > > > > > > db.menu_item.restaurant.requires=IS_IN_DB > > > > > > (db,'restaurant.id','restaurant.name') > > > > > > > However, I don't know how I can sort the results to not be > > > > > > alphabetical, but rather, a manually assigned sort column I've > > > > > > provided myself (or, perhaps, simply the order in which they were > > > > > > added to the database). > > > > > > > Any ideas? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

