How do I correct this error: AttributeError: 'NoneType' object has no attribute 'id'

30 views
Skip to first unread message

Maurice Waka

unread,
May 14, 2021, 8:49:41 AM5/14/21
to web2py-users
I have a small code with this:

db.define_table('book',                         
                Field('name',requires = IS_NOT_EMPTY()),
                Field('category',
                      requires = IS_IN_SET(['Politics','Finance','Fiction','Wellness']),
                      default = 'Politics'),        
                Field('price', 'integer',requires = IS_NOT_EMPTY()),
                Field('image','upload'),
                Field('selling_type',requires = IS_IN_SET(['Bids','Buy']),default = 'Bid'),
                Field('book_author',
                      db.auth_user,
                      default=auth.user_id,
                      writable=False,
                      readable=False,
                      requires=IS_IN_DB(db, db.auth_user.id,'%(first_name)s')),
                Field('description','text',requires = IS_NOT_EMPTY()),
                Field('created_on','datetime',
                      default=request.now,
                      update=request.now,
                      writable=False))


product = db(book_author.id==db.book.book_author).select(db.book.ALL)


But I get this Error:

    product = db(book_author.id==db.book.book_author).select(db.book.ALL)
AttributeError: 'NoneType' object has no attribute 'id'

Maurice Waka

unread,
May 14, 2021, 10:01:21 AM5/14/21
to web2py-users

Seems to work after restarting the system
Reply all
Reply to author
Forward
0 new messages