This is help, thank you.
On Tuesday, December 23, 2014 at 4:33:54 PM UTC+8, William Chen wrote:
>
> Hi Chris, I had the same problem and found this thread when I was
> searching for a solution.
>
> The solution is to manually create 2 or 3 comments using appadmin.
>
> If table B references table A, you need to populate table A before you
> populate table B, or 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 a couple of new comments using appadmin, before
> we populate the table comm.
>
> Hope this helps.
>
>
> On Wednesday, 28 May 2014 23:05:06 UTC+8, Chris Simpson wrote:
>>
>>
>> Hi Uri,
>>
>> Did you ever find a solution to this?
>> On Wednesday, May 14, 2014 12:01:29 PM UTC+2, Uri Tamir wrote:
>>>
>>> Hi all,
>>> I've been following Massimo's video tutorials
>>> <http://vimeo.com/76047107> (which are *great!* thanks Massimo)
>>>
>>> when trying to build the reddit clone and populate it i get a ticket
>>> - <class 'sqlite3.IntegrityError'> foreign key constraint failed
>>>
>>> the database was populated with users and posts but not with comments. I
>>> tried to make sure my code is exactly as the code Massimo showed but /w no
>>> success.
>>>
>>> any suggestions?
>>>
>>> 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 populate
>>> if 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()
>>>
>>>
>>>
--
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 the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.