When you do attendees = models.ManyToManyField(User, through='Attendance')
in Django, it does not create any field. It just informs Django of the many to many and Django uses it to build forms. Web2py does not automatically builds forms out of many to many (unless you use Tagging as Fran suggested) because this requires JOINS and joins do not work on Google App Engine. Anyway if you are just translating the mode; this is the equivalent: db.define_table('event', Field('description','text'), Field('creation_date','datetime',default=request.now), Field('start_date','datetime'), Field('creator',db.auth_user,default=auth.user.id if auth.is_logged_in() else 0), Field('latest','boolean',default=True)) db.define_table('attendance', Field('user',db.auth_user), Field('event',db.event), Field('registration_date','datetime',default=request.now)) you may want to add: db.event.description.requires=IS_NOT_EMPTY() db.attendance.user.requires=IS_IN_DB(db,'auth_user.id','%(first_name) s','%(last_name)s') db.attendance.event.requires=IS_IN_DB(db,'event.id','%(description)s') On Jul 28, 11:47 am, __future__ <wrigh...@gmail.com> wrote: > In trying to better wrap my head around the workings of web2py, I am > attempting to convert a Django tutorial I used a while back to learn > Django into web2py-speak. It is a series of video tutorials that walk > one through building a twitter-ish site (Start The Dark). > > I am already confused about how to implement the Django style many-to- > many relationship in web2py. > > The model starts out in the Django tutorial like so (this is the just > the begining): > > # in models.py > > from django.db import models > from datetime import datetime, timedelta > from django.contrib.auth.models import User > class Event(models.Model): > > description = models.TextField() > creation_date = models.DateTimeField(default=datetime.now) > start_date = models.DateTimeField(blank=True, null=True) > creator = models.ForeignKey(User, > related_name='event_creator_set') > attendees = models.ManyToManyField(User, through='Attendance') > latest = models.BooleanField(default=True) > > def __unicode__(self): > return self.description > > class Attendance(models.Model): > > user = models.ForeignKey(User) > event = models.ForeignKey(Event) > registration_date = models.DateTimeField(default=datetime.now) > > def __unicode__(self): > return u"%s is attending %s" % (self.username, self.event) > > The ultimate result at the end of the tutorial series is a site where > users can post one event per day and other users can "attend" events > > I left out some of the requirements here like the custom managers and > querysets. > for clarity and brevity. > > How would I do this in web2py, assuming i wanted to use the auth_user > table for users? > > Once I figure out how, I would like to do the whole project w/ > screencasts. I think it will help my understanding a lot and it might > make a nice learning guide for others coming from Django > > Thanks, > > __future__ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---