I can't post into a DAL Field

17 views
Skip to first unread message

Maurice Waka

unread,
Apr 1, 2017, 11:56:41 AM4/1/17
to web2py-users
I have this:
Post =define_table('post'
                            Field('message', 'text', requires=IS_NOT_EMPTY, notnull=True),
                            Field('reply', 'text', requires=IS_NOT_EMPTY).
                            auth.signatue
        )
Post.is_active.readable=False
Post.is_active.writable=False

controller:

def index():
    code....
    db.post.reply.insert(name='report').....to insert into the reply collumn

I get error that:
AttributeError:'Field' object has no attribute 'insert'

If I use:
db.post.insert(name='report')

SyntaxError: Field name does not belong to the table

I thought/Learned that to insert: you do e.g.

db.person.insert(name="Luca")

db.commit()

What am i doing wrong, and how can i correct it?
regards

Anthony

unread,
Apr 1, 2017, 3:49:09 PM4/1/17
to web2py-users
It is not clear what you are trying to do. You can only insert values in fields that exist -- there is no "name" field in your table, so you cannot insert a value for a "name" field. If you want to insert a value for "reply", then you must specify the "reply" field:

db.post.insert(reply='report')

Where does "name" come from in this scenario?

Anthony

Maurice Waka

unread,
Apr 2, 2017, 4:13:50 AM4/2/17
to web...@googlegroups.com
Great Antony!. But wait, now I have a new issue:
IntegrityError: NOT NULL constraint failed: post.message

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/u801DTQdpHE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Maurice Waka

unread,
Apr 2, 2017, 6:04:41 AM4/2/17
to web...@googlegroups.com
I had to create another table for 'reply', and it worked. 
I appreciate your continuous support!!
Regards
Reply all
Reply to author
Forward
0 new messages