Yes I tried one at a time but it does not work. And it shows those
errors I mentioned.

On Oct 21, 10:38 pm, mdipierro <[email protected]> wrote:
> Does it work? You can only have one of the two
>
> On Oct 21, 9:15 am, Luther Goh Lu Feng <[email protected]> wrote:
>
>
>
>
>
>
>
> > Oops, of course I did change the default as advised:
>
> >  Field('membership_id', db.auth_membership, default=0),
> >  Field('membership_id', auth.settings.table_membership, default=0),
>
> > On Oct 21, 10:13 pm, Luther Goh Lu Feng <[email protected]> wrote:
>
> > > Thanks for the tip.
>
> > > I tried the uncommenting the 2 lines separately and got the following
> > > errors. Any tips?
>
> > > "Field('membership_id', db.auth_membership, default=''),":
>
> > > Traceback (most recent call last):
> > >   File "/home/luther/roverus/gluon/restricted.py", line 188, in
> > > restricted
> > >     exec ccode in environment
> > >   File "/home/luther/roverus/applications/roverus/models/rmodels.py",
> > > line 18, in <module>
> > >     Field('membership_id', db.auth_membership, default=0),
> > >   File "/home/luther/roverus/gluon/sql.py", line 1385, in __getattr__
> > >     return dict.__getitem__(self,key)
> > > KeyError: 'auth_membership'
>
> > >  "Field('membership_id', auth.settings.table_membership, default=''),
> > > ":
>
> > > Traceback (most recent call last):
> > >   File "/home/luther/roverus/gluon/restricted.py", line 188, in
> > > restricted
> > >     exec ccode in environment
> > >   File "/home/luther/roverus/applications/roverus/models/rmodels.py",
> > > line 20, in <module>
> > >     format='%(username)s'
> > >   File "/home/luther/roverus/gluon/sql.py", line 1365, in define_table
> > >     t._create(migrate=migrate, fake_migrate=fake_migrate)
> > >   File "/home/luther/roverus/gluon/sql.py", line 1726, in _create
> > >     elif field.type.startswith('reference'):
> > > AttributeError: 'NoneType' object has no attribute 'startswith'
>
> > > On Oct 21, 9:17 pm, mdipierro <[email protected]> wrote:
>
> > > > They are both fine but default cannot be a string, must be 0.
>
> > > > On Oct 21, 6:21 am, Luther Goh Lu Feng <[email protected]> wrote:
>
> > > > > I have the following custom user model. I am trying to reference the 
> > > > > membership
> > > > > type so that when users are created by administrators, they can 
> > > > > assigned
> > > > > different roles. Attention to be drawn to the 2 lines commented out 
> > > > > at the
> > > > > bottom, which I have tried to make the reference but failed. Any tips?
>
> > > > > db.define_table(auth.settings.table_user_name,
> > > > >     Field('username', 'string', length=255, required=True,
> > > > > requires=IS_NOT_EMPTY(), unique=True, label="Username"),
> > > > >     Field('first_name', 'string', length=255, required=True,
> > > > > requires=IS_NOT_EMPTY(), label="First name"),
> > > > >     Field('last_name', 'string', length=255, required=True,
> > > > > requires=IS_NOT_EMPTY(), label="Last name"),
> > > > >     Field('password', 'password', length=40, required=True,
> > > > > requires=[IS_NOT_EMPTY(),CRYPT(key="sha1:theultimatesuperrover")],
> > > > >  readable=False,  label="Password"),
> > > > >     Field('last_login', 'datetime', writable=False, readable=False,
> > > > > update=request.now),
> > > > >     Field('registration_key', length=512, writable=False, 
> > > > > readable=False,
> > > > > default=''),
> > > > >     Field('reset_password_key', length=512, writable=False, 
> > > > > readable=False,
> > > > > default=''),
> > > > >     Field('registration_id', length=512, writable=False, 
> > > > > readable=False,
> > > > > default=''),
> > > > >     Field('class_id', 'reference classes', default=''),
> > > > >     #Field('membership_id', db.auth_membership, default=''),
> > > > >     #Field('membership_id', auth.settings.table_membership, 
> > > > > default=''),
> > > > >     format='%(username)s'
> > > > > )

Reply via email to