...I'm not sure to understand how it works. You've use the categories, we 
can think that each project have only one category. So relationship is one 
to many.
For skills it's many to many. One project can have more than one skill, a 
skill can have more than one project.
So you need another table, in my example skills_and_projects, to save this 
relationship.

Il giorno venerdì 5 agosto 2016 18:07:06 UTC+2, Ron Chatterjee ha scritto:
>
> Think about the problem this way.
>
> db.define_table('category',
>                 Field('name' , notnull=True, unique=True),
>                 format='%(name)s')
>
> db.define_table("Project",
>                 Field('select_category', 'reference category'),
>                 Field('Title', 'string'),)
>
> def show_project_by_category():
>     category = db.category(request.args(0)) #This is something lets say 
> people click from a drop down menu list of all the categories
>     project_query = db(db.Project.select_category == category.id) #Which 
> one they selected. 
>     projects = project_query.select(orderby=db.Project.Title) #From that, 
> I pick the referenced project.
>     response.view = 'default/show_project.html' #just display that.
>     return locals()
>
>
> Lets say you create a drop down list or categories
> your request.args(0) is the id of your category (like 1,2,3...). From that 
> you can access exactly which project it is. What you have is another 
> derivation of skills and etc...
>
>
>
>
>
>
> On Friday, August 5, 2016 at 11:38:55 AM UTC-4, Gael Princivalle wrote:
>>
>> Hello all.
>>
>> I have a many to many relationship like that:
>>
>> db.define_table('skills',
>>                 Field('name', type='string', requires=IS_NOT_EMPTY()),
>>                 format='%(name)s')
>>
>> db.define_table("projects",
>>                 Field('title', type='string', requires=IS_NOT_EMPTY()),
>>                                   format='%(title)s')
>>
>> db.define_table('skills_and_projects',
>>                 Field('skill', 'reference skills'),
>>                 Field('project', 'reference projects'))
>>
>> Which is the best way to build an interface for adding a project record 
>> including the skills?
>> I've saw these widgets:
>> SQLFORM.widgets.multiple.widget
>> SQLFORM.widgets.checkboxes.widget
>>
>> But it seems that they are made only to deal with string lists.
>>
>> Someone have a suggestion?
>>
>> Thanks.
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to