db.define_table('category', Field('name', requires = (IS_SLUG(), IS_LOWER(), IS_NOT_IN_DB(db, 'category.name'))))
db.define_table('post', Field('category', 'reference category', readable=False, writable=False), Field('title', 'string', requires=IS_NOT_EMPTY()), Field('url', requires=IS_EMPTY_OR(IS_URL())), Field('body', 'text', requires=IS_NOT_EMPTY()), Field('votes', 'integer', default=0, readable=False, writable=False), auth.signature) # created_on, created_by, modified_on, modified_by, is_active
db.define_table('post_vote', Field('post', 'reference post'), Field('score', 'integer', default=+1), # numerical representation of votes auth.signature)
db.define_table('comm', Field('post', 'reference post'), Field('parent_comm', 'reference comm'), Field('votes', 'integer'), Field('body', 'text'), auth.signature)
db.define_table('comm_vote', Field('comm', 'reference comm'), Field('score', 'integer', default=+1), # numerical representation of votes auth.signature)
from gluon.contrib.populate import populateif db(db.auth_user).count()<2: populate(db.auth_user, 100) db.commit()if db(db.post).count()<2: populate(db.post, 500) db.commit()if db(db.comm).count()<2: populate(db.comm, 1000) db.commit()
Hi Chris, I had the same problem and found this thread when I was searching for a solution.
The solution is to simply create 1 or more comments using app admin.If table B references table A, then you need populate to populate table A before you populate table B, else there will be an error. In our case, the table comm references to itself in this line:
Field('parent_comm', 'reference comm')
So we need to manually add new comments, before we populate the table comm.Hope this helps.
On Wednesday, 28 May 2014 23:05:06 UTC+8, Chris Simpson wrote:
--
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/9L1Ycuw7ZPo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.