Thanks Stifan,
I don't have any code, but just type this into the shell:
from gluon.contrib.populate import populate
populate(db.auth_user,10)
but you have shown me another way I can do it.
On Friday, August 7, 2015 at 12:48:41 AM UTC-7, 黄祥 wrote:
>
> IntegrityError: FOREIGN KEY constraint failed ?
> perhaps you modify auth_user table, could you show some code.
>
> no, i don't use populate, i insert it manually.
> e.g.
> controllers/install.py
> # -*- coding: utf-8 -*-
>
> # index
> def index():
> if db(db.auth_permission).isempty() and db(db.auth_membership).isempty():
> # group
> auth.add_group('Manager', 'Manager')
> auth.add_group('Admin', 'Admin')
> # user
> db.auth_user.bulk_insert([{"first_name" : "Admin", "last_name" : "Admin",
> "email" : "[email protected] <javascript:>", "username" : "admin",
> "password" : db.auth_user.password.validate("a")[0] },
> {"first_name" : "User", "last_name" : "User",
> "email" : "[email protected] <javascript:>", "username" : "user",
> "password" : db.auth_user.password.validate("a")[0] } ] )
>
> """
> membership (group_id, user_id)
> """
> auth.add_membership("1", "1")
> auth.add_membership("2", "1")
> auth.add_membership("2", "2")
>
> # permission
> auth.add_permission(1, "impersonate", "auth_user", 2)
>
> session.flash = T('Installation Done')
> redirect(URL('default', 'index'))
>
> best regards,
> stifan
>
--
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.